From 66dc918d325d5552452870626e412eca737f0f00 Mon Sep 17 00:00:00 2001 From: Wes Kocher Date: Mon, 28 Sep 2015 13:16:59 -0700 Subject: [PATCH 1/3] Rebase PR 31 onto current master --- js/BugData.js | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/js/BugData.js b/js/BugData.js index 26eb01a..018d470 100644 --- a/js/BugData.js +++ b/js/BugData.js @@ -2,6 +2,8 @@ var BugData = { bugs: {}, + productsArray: [], + assignees: {}, trackingFlag: null, statusFlag: null, fields: 'id,resolution,status,whiteboard,keywords,target_milestone,summary,product,component,flags,assigned_to', @@ -84,6 +86,7 @@ var BugData = { bug.milestone = UI.htmlEncode(bugObj.target_milestone); bug.summary = UI.htmlEncode(bugObj.summary); bug.product = bugObj.product; + bug.component = bugObj.component; bug.id = bugObj.id; if (typeof bug.id == 'string') bug.id = UI.htmlEncode(bug.id); @@ -107,7 +110,7 @@ var BugData = { if (this.statusFlag) bug.statusFlag = bugObj[this.statusFlag]; - bug.isUnassigned = /^nobody@(?:mozilla.org|nss.bugs)$/.test(bugObj.assigned_to.name); + bug.assignee = bugObj.assigned_to; bug.intestsuite = ' '; bug.testsuiteFlagID = -1; @@ -129,9 +132,65 @@ var BugData = { parseData: function BD_parseData(data, loadCallback) { data.forEach(this.makeBug, this); + this.getDefaultAssignees(data); if (this.notYetLoaded.length == 0) this.loadCallback(); else this.loadMore(); + }, + + /* + * Get default assignees for all products in this push from the API. + * We have to get this separate from the bugs query because API doesn't + * expose that information from the bugs endpoint. + */ + getDefaultAssignees: function BD_getDefaultAssignees(data) { + data.forEach(this.parseProducts, this); + var productQueryString = "/product?"; + for(var i in this.productsArray) { + productQueryString += "names=" + this.productsArray[i] + "&"; + } + productQueryString += "include_fields=name,components.name,components.default_assigned_to"; + + var callback = function BD_AssigneeCallback(errmsg, data) { + if (errmsg) { + self.errorCallback(errmsg); + } else { + for(var prod in data) { + BugData.assignees[data[prod].name] = {} + for(var component in data[prod]["components"]) { + BugData.assignees[data[prod].name][data[prod]["components"][component].name] = data[prod]["components"][component].default_assigned_to; + } + } + for(var bug in BugData.bugs) { + BugData.recheckAssignee(BugData.bugs[bug]); + } + } + }; + + var bugzilla = bz.createClient({timeout: 30000}); + bugzilla.APIRequest(productQueryString, "GET", callback, "products"); + }, + + /* + * Create an array of all unique products in this push + */ + parseProducts: function BD_parseProducts(bugObj) { + if (bugObj.product in this.assignees) { + } else { + this.productsArray.push(bugObj.product); + } + }, + + /* + * Now that we have the default assignee values, compare against the + * current assignee, and store that for use later. + */ + recheckAssignee: function BD_recheckAssignee(bug) { + if (this.assignees[bug.product][bug.component] == bug.assignee) { + bug.isUnassigned = true; + } else { + bug.isUnassigned = false; + } } }; From 5ab4cce547d17a3f962be3475717f58de9806ff9 Mon Sep 17 00:00:00 2001 From: Wes Kocher Date: Mon, 28 Sep 2015 13:40:05 -0700 Subject: [PATCH 2/3] Review comments --- js/BugData.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/js/BugData.js b/js/BugData.js index 018d470..7134176 100644 --- a/js/BugData.js +++ b/js/BugData.js @@ -146,22 +146,20 @@ var BugData = { */ getDefaultAssignees: function BD_getDefaultAssignees(data) { data.forEach(this.parseProducts, this); - var productQueryString = "/product?"; - for(var i in this.productsArray) { - productQueryString += "names=" + this.productsArray[i] + "&"; - } - productQueryString += "include_fields=name,components.name,components.default_assigned_to"; + var productQueryString = "/product?names=" + this.productsArray.join("&names=") + + "include_fields=name,components.name,components.default_assigned_to"; var callback = function BD_AssigneeCallback(errmsg, data) { if (errmsg) { self.errorCallback(errmsg); } else { - for(var prod in data) { - BugData.assignees[data[prod].name] = {} - for(var component in data[prod]["components"]) { - BugData.assignees[data[prod].name][data[prod]["components"][component].name] = data[prod]["components"][component].default_assigned_to; - } - } + data.forEach(function(prod) { + var prodName = prod.name; + BugData.assignees[prodName] = {}; + data[prod].components.forEach(function(component) { + BugData.assignees[prodName][component.name] = component.default_assigned_to; + }); + }); for(var bug in BugData.bugs) { BugData.recheckAssignee(BugData.bugs[bug]); } @@ -176,8 +174,7 @@ var BugData = { * Create an array of all unique products in this push */ parseProducts: function BD_parseProducts(bugObj) { - if (bugObj.product in this.assignees) { - } else { + if (!(bugObj.product in this.assignees)) { this.productsArray.push(bugObj.product); } }, From 337e1ff9bb996456dc6d650e5d38a6ac24456cb6 Mon Sep 17 00:00:00 2001 From: Wes Kocher Date: Mon, 28 Sep 2015 16:17:14 -0700 Subject: [PATCH 3/3] Fix after comments --- js/BugData.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/BugData.js b/js/BugData.js index 7134176..98fa217 100644 --- a/js/BugData.js +++ b/js/BugData.js @@ -156,7 +156,7 @@ var BugData = { data.forEach(function(prod) { var prodName = prod.name; BugData.assignees[prodName] = {}; - data[prod].components.forEach(function(component) { + prod.components.forEach(function(component) { BugData.assignees[prodName][component.name] = component.default_assigned_to; }); });