# HG changeset patch # User Atul Varma # Date 1272243354 25200 # Node ID 4ec651cc606e28090043b27bd1eda381e36357a2 # Parent fbaf7857e7c34d25936b20e6dd1ddcfecd4e109f 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. diff -r fbaf7857e7c3 -r 4ec651cc606e js/modules/app.js --- 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 = {