@@ -33,6 +33,11 @@ function getContributorInfo() {
3333 // global variable
3434 if ( statsScope === "org" ) {
3535 ret . user = org ;
36+ ret . repoPath = org ;
37+ }
38+
39+ if ( statsScope === "account" ) {
40+ ret . repoPath = "__self" ;
3641 }
3742
3843 injectInitialUI ( ret ) ;
@@ -51,19 +56,31 @@ function buildUrl({base, q: {type, filterUser, author, repo, user}, sort, order,
5156 query += `${ order ? `&order=${ order } ` : "" } ` ;
5257 query += `${ per_page ? `&per_page=${ per_page } ` : "" } ` ;
5358 query += `${ sort ? `&sort=${ sort } ` : "" } ` ;
59+
5460 return query ;
5561}
5662
5763function contributorCount ( { access_token, contributor, user, repoPath, old = { } , type} ) {
64+ let repo = repoPath ;
65+
66+ // global variable
67+ if ( statsScope === "org" ) {
68+ repo = undefined ;
69+ repoPath = repoPath . split ( "/" ) [ 0 ] ;
70+ } else if ( statsScope === "account" ) {
71+ repo = undefined ;
72+ repoPath = "__self" ;
73+ }
74+
5875 let searchURL = buildUrl ( {
5976 access_token,
6077 base : "https://api.github.com/search/issues" ,
6178 order : "asc" ,
6279 per_page : "1" ,
6380 q : {
6481 type,
82+ repo,
6583 author : contributor ,
66- repo : user ? undefined : repoPath ,
6784 user : user
6885 } ,
6986 sort : "created"
@@ -174,13 +191,16 @@ function injectInitialUI({ contributor, repoPath }) {
174191 <div class="dropdown-header">
175192 View options
176193 </div>
177- <a class="dropdown-item" id="gce-across-this-org">
178- across this org
179- </a>
180194 <a class="dropdown-item selected" id="gce-in-this-repo">
181195 ${ $checkbox }
182196 in this repo
183197 </a>
198+ <a class="dropdown-item" id="gce-in-this-org">
199+ in this org
200+ </a>
201+ <a class="dropdown-item" id="gce-in-this-account">
202+ in this account
203+ </a>
184204 </ul>
185205 </div>
186206 </div>` ;
@@ -200,31 +220,55 @@ ${dropdown}
200220 update ( getContributorInfo ( ) ) ;
201221 } ) ;
202222
203- let $acrossThisOrg = $ ( "#gce-across -this-org" ) ;
223+ let $inThisOrg = $ ( "#gce-in -this-org" ) ;
204224 let $inThisRepo = $ ( "#gce-in-this-repo" ) ;
225+ let $inThisAccount = $ ( "#gce-in-this-account" ) ;
205226 let $dropdownText = $ ( "#gce-dropdown-text" ) ;
206227
207- $acrossThisOrg . dom [ 0 ] . addEventListener ( "click" , function ( ) {
208- $acrossThisOrg . addClass ( "selected" ) ;
228+ $inThisOrg . dom [ 0 ] . addEventListener ( "click" , function ( ) {
229+ $inThisOrg . addClass ( "selected" ) ;
209230 $inThisRepo . removeClass ( "selected" ) ;
210- $acrossThisOrg . html ( `${ $checkbox } across this org` ) ;
211- $inThisRepo . html ( 'in this repo' ) ;
212- $dropdownText . html ( 'across this org' ) ;
231+ $inThisAccount . removeClass ( "selected" ) ;
232+
233+ $inThisOrg . html ( `${ $checkbox } in this org` ) ;
234+ $dropdownText . html ( "in this org" ) ;
235+
236+ $inThisAccount . html ( "in this account" ) ;
237+ $inThisRepo . html ( "in this repo" ) ;
213238 // global
214239 statsScope = "org" ;
215240 update ( getContributorInfo ( ) ) ;
216241 } ) ;
217242
218243 $inThisRepo . dom [ 0 ] . addEventListener ( "click" , function ( ) {
219244 $inThisRepo . addClass ( "selected" ) ;
220- $acrossThisOrg . removeClass ( "selected" ) ;
245+ $inThisOrg . removeClass ( "selected" ) ;
246+ $inThisAccount . removeClass ( "selected" ) ;
247+
221248 $inThisRepo . html ( `${ $checkbox } in this repo` ) ;
222- $acrossThisOrg . html ( 'across this org' ) ;
223- $dropdownText . html ( 'in this repo' ) ;
249+ $dropdownText . html ( "in this repo" ) ;
250+
251+ $inThisAccount . html ( "in this account" ) ;
252+ $inThisOrg . html ( "in this org" ) ;
224253 // global
225254 statsScope = "repo" ;
226255 update ( getContributorInfo ( ) ) ;
227256 } ) ;
257+
258+ $inThisAccount . dom [ 0 ] . addEventListener ( "click" , function ( ) {
259+ $inThisAccount . addClass ( "selected" ) ;
260+ $inThisOrg . removeClass ( "selected" ) ;
261+ $inThisRepo . removeClass ( "selected" ) ;
262+
263+ $inThisAccount . html ( `${ $checkbox } in this account` ) ;
264+ $dropdownText . html ( "in this account" ) ;
265+
266+ $inThisRepo . html ( "in this repo" ) ;
267+ $inThisOrg . html ( "in this org" ) ;
268+ // global
269+ statsScope = "account" ;
270+ update ( getContributorInfo ( ) ) ;
271+ } ) ;
228272}
229273
230274function updateTextNodes ( { prText, issueText, lastUpdate } ) {
@@ -247,7 +291,14 @@ function updateTextNodes({ prText, issueText, lastUpdate }) {
247291function update ( { contributor, repoPath, currentNum, user } ) {
248292 getStorage ( contributor , repoPath )
249293 . then ( ( storage ) => {
250- let storageRes = storage [ contributor ] [ user ? user : repoPath ] = { } ;
294+ let path = repoPath ;
295+ if ( user ) {
296+ path = user ;
297+ } else if ( statsScope === "account" ) {
298+ path = "__self" ;
299+ }
300+
301+ let storageRes = storage [ `${ contributor } |${ path } ` ] || { } ;
251302
252303 if ( storageRes . prs || storageRes . issues ) {
253304 updateTextNodes ( appendPRText ( currentNum , storageRes ) ) ;
0 commit comments