Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 57 additions & 1 deletion js/BugData.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -129,9 +132,62 @@ 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?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 {
data.forEach(function(prod) {
var prodName = prod.name;
BugData.assignees[prodName] = {};
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]);
}
}
};

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)) {
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;
}
}
};