Mercurial > bugzilla-dashboard
diff js/modules/app.js @ 71:4ec651cc606e
we now only make one request at a time to the bugzilla server, which reduces app responsiveness but makes us less of a douche to the server.
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Sun, 25 Apr 2010 17:55:54 -0700 |
parents | 6f5b5b404066 |
children | 0eab9a3ff12f |
line wrap: on
line diff
--- a/js/modules/app.js Sun Apr 25 14:37:56 2010 -0700 +++ b/js/modules/app.js Sun Apr 25 17:55:54 2010 -0700 @@ -42,7 +42,50 @@ }; }; +Require.modules["app/bugzilla-serial"] = function(exports, require) { + const EVENTS = ["abort", "error", "load"]; + + var myproto = require("bugzilla"); + var active = null; + var queue = []; + + function enqueue(bugzilla, options) { + queue.push({bugzilla: bugzilla, options: options}); + if (!active) + activateNextInQueue(); + } + + function activateNextInQueue() { + if (queue.length) { + var entry = queue.splice(0, 1)[0]; + var xhr = myproto.ajax.call(entry.bugzilla, entry.options); + EVENTS.forEach(function(name) { + xhr.addEventListener(name, onDone, false); + }); + active = xhr; + } else + active = null; + } + + function onDone(event) { + var xhr = event.target; + EVENTS.forEach(function(name) { + xhr.removeEventListener(name, onDone, false); + }); + activateNextInQueue(); + }; + + exports.Bugzilla = { + ajax: function ajax(options) { + enqueue(this, options); + }, + __proto__: myproto + }; +}; + Require.modules["app/bugzilla-auth"] = function(exports, require) { + var myproto = require("app/bugzilla-serial").Bugzilla; + exports.Bugzilla = { ajax: function ajax(options) { var user = require("app/login").get(); @@ -54,9 +97,9 @@ options.data.password = user.password; } - return this.__proto__.ajax.call(this, options); + return myproto.ajax.call(this, options); }, - __proto__: require("bugzilla") + __proto__: myproto }; }; @@ -512,25 +555,16 @@ }; function update(myUsername) { + report("#code-reviews", myUsername, + {status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"], + flag_DOT_requestee: myUsername}); + report("#assigned-bugs", myUsername, {status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"], email1: myUsername, email1_type: "equals", email1_assigned_to: 1}); - report("#fixed-bugs", myUsername, - {resolution: ["FIXED"], - changed_after: timeAgo(MS_PER_WEEK), - email1: myUsername, - email1_type: "equals", - email1_assigned_to: 1, - email1_reporter: 1, - email1_cc: 1}); - - report("#code-reviews", myUsername, - {status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"], - flag_DOT_requestee: myUsername}); - report("#reported-bugs", myUsername, {status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"], email1: myUsername, @@ -549,6 +583,15 @@ email2_type: "not_equals", email2_assigned_to: 1, email2_reporter: 1}); + + report("#fixed-bugs", myUsername, + {resolution: ["FIXED"], + changed_after: timeAgo(MS_PER_WEEK), + email1: myUsername, + email1_type: "equals", + email1_assigned_to: 1, + email1_reporter: 1, + email1_cc: 1}); }; var refreshCommand = {