diff --git a/addon/background.js b/addon/background.js index 2572df3..f1d1279 100644 --- a/addon/background.js +++ b/addon/background.js @@ -294,7 +294,7 @@ var MyQOnly = { async updateBugzilla(settings) { let apiKey = settings.apiKey; if (!apiKey) { - return { reviewTotal: 0, needinfoTotal: 0, }; + return { review: 0, needinfo: 0, }; } // I'm not sure how much of this is necessary - I just looked at what @@ -326,19 +326,31 @@ var MyQOnly = { if (bugzillaData.error) { throw new Error(`Bugzilla request failed: ${bugzillaData.error.message}`); } - let reviewTotal = + + if (settings.allBugzillaFlags) { + let flagCounts = {}; + bugzillaData.result.result.requestee.map(f => { + if (!(f.type in flagCounts)) { + flagCounts[f.type] = 0; + } + flagCounts[f.type]++; + }); + return flagCounts; + } + + let review = bugzillaData.result.result.requestee.filter(f => { return f.type == "review"; }).length; - let needinfoTotal = 0; + let needinfo = 0; if (settings.needinfos) { - needinfoTotal =bugzillaData.result.result.requestee.filter(f => { + needinfo = bugzillaData.result.result.requestee.filter(f => { return f.type == "needinfo"; }).length; } - return { reviewTotal, needinfoTotal, }; + return { review, needinfo, }; }, async updateGitHub(settings) { @@ -495,7 +507,9 @@ var MyQOnly = { total += state.data.reviewTotal || 0; if (state.type == "bugzilla") { - total += state.data.needinfoTotal || 0; + for (let count of Object.values(state.data)) { + total += count; + } } } @@ -521,10 +535,9 @@ var MyQOnly = { } case "bugzilla": { data = await this.updateBugzilla(service.settings); - console.log(`Found ${data.reviewTotal} Bugzilla reviews ` + - "to do"); - console.log(`Found ${data.needinfoTotal} Bugzilla needinfos ` + - "to do"); + for (let [flag, count] of Object.entries(data)) { + console.log(`Found ${count} Bugzilla ${flag}s to do`); + } break; } case "github": { diff --git a/addon/content/options/options.html b/addon/content/options/options.html index b1c3252..71526a0 100644 --- a/addon/content/options/options.html +++ b/addon/content/options/options.html @@ -38,6 +38,10 @@