Mercurial > bugzilla-dashboard
comparison 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 |
comparison
equal
deleted
inserted
replaced
70:fbaf7857e7c3 | 71:4ec651cc606e |
---|---|
40 | 40 |
41 callbacks.forEach(function(cb) { cb(info); }); | 41 callbacks.forEach(function(cb) { cb(info); }); |
42 }; | 42 }; |
43 }; | 43 }; |
44 | 44 |
45 Require.modules["app/bugzilla-serial"] = function(exports, require) { | |
46 const EVENTS = ["abort", "error", "load"]; | |
47 | |
48 var myproto = require("bugzilla"); | |
49 var active = null; | |
50 var queue = []; | |
51 | |
52 function enqueue(bugzilla, options) { | |
53 queue.push({bugzilla: bugzilla, options: options}); | |
54 if (!active) | |
55 activateNextInQueue(); | |
56 } | |
57 | |
58 function activateNextInQueue() { | |
59 if (queue.length) { | |
60 var entry = queue.splice(0, 1)[0]; | |
61 var xhr = myproto.ajax.call(entry.bugzilla, entry.options); | |
62 EVENTS.forEach(function(name) { | |
63 xhr.addEventListener(name, onDone, false); | |
64 }); | |
65 active = xhr; | |
66 } else | |
67 active = null; | |
68 } | |
69 | |
70 function onDone(event) { | |
71 var xhr = event.target; | |
72 EVENTS.forEach(function(name) { | |
73 xhr.removeEventListener(name, onDone, false); | |
74 }); | |
75 activateNextInQueue(); | |
76 }; | |
77 | |
78 exports.Bugzilla = { | |
79 ajax: function ajax(options) { | |
80 enqueue(this, options); | |
81 }, | |
82 __proto__: myproto | |
83 }; | |
84 }; | |
85 | |
45 Require.modules["app/bugzilla-auth"] = function(exports, require) { | 86 Require.modules["app/bugzilla-auth"] = function(exports, require) { |
87 var myproto = require("app/bugzilla-serial").Bugzilla; | |
88 | |
46 exports.Bugzilla = { | 89 exports.Bugzilla = { |
47 ajax: function ajax(options) { | 90 ajax: function ajax(options) { |
48 var user = require("app/login").get(); | 91 var user = require("app/login").get(); |
49 | 92 |
50 if (user.isAuthenticated) { | 93 if (user.isAuthenticated) { |
52 options.data = {}; | 95 options.data = {}; |
53 options.data.username = user.username; | 96 options.data.username = user.username; |
54 options.data.password = user.password; | 97 options.data.password = user.password; |
55 } | 98 } |
56 | 99 |
57 return this.__proto__.ajax.call(this, options); | 100 return myproto.ajax.call(this, options); |
58 }, | 101 }, |
59 __proto__: require("bugzilla") | 102 __proto__: myproto |
60 }; | 103 }; |
61 }; | 104 }; |
62 | 105 |
63 Require.modules["app/commands"] = function(exports, require) { | 106 Require.modules["app/commands"] = function(exports, require) { |
64 var commands = {}; | 107 var commands = {}; |
510 var defaults = { | 553 var defaults = { |
511 changed_after: timeAgo(MS_PER_WEEK * 14) | 554 changed_after: timeAgo(MS_PER_WEEK * 14) |
512 }; | 555 }; |
513 | 556 |
514 function update(myUsername) { | 557 function update(myUsername) { |
558 report("#code-reviews", myUsername, | |
559 {status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"], | |
560 flag_DOT_requestee: myUsername}); | |
561 | |
515 report("#assigned-bugs", myUsername, | 562 report("#assigned-bugs", myUsername, |
516 {status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"], | 563 {status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"], |
517 email1: myUsername, | 564 email1: myUsername, |
518 email1_type: "equals", | 565 email1_type: "equals", |
519 email1_assigned_to: 1}); | 566 email1_assigned_to: 1}); |
520 | |
521 report("#fixed-bugs", myUsername, | |
522 {resolution: ["FIXED"], | |
523 changed_after: timeAgo(MS_PER_WEEK), | |
524 email1: myUsername, | |
525 email1_type: "equals", | |
526 email1_assigned_to: 1, | |
527 email1_reporter: 1, | |
528 email1_cc: 1}); | |
529 | |
530 report("#code-reviews", myUsername, | |
531 {status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"], | |
532 flag_DOT_requestee: myUsername}); | |
533 | 567 |
534 report("#reported-bugs", myUsername, | 568 report("#reported-bugs", myUsername, |
535 {status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"], | 569 {status: ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"], |
536 email1: myUsername, | 570 email1: myUsername, |
537 email1_type: "equals", | 571 email1_type: "equals", |
547 email1_cc: 1, | 581 email1_cc: 1, |
548 email2: myUsername, | 582 email2: myUsername, |
549 email2_type: "not_equals", | 583 email2_type: "not_equals", |
550 email2_assigned_to: 1, | 584 email2_assigned_to: 1, |
551 email2_reporter: 1}); | 585 email2_reporter: 1}); |
586 | |
587 report("#fixed-bugs", myUsername, | |
588 {resolution: ["FIXED"], | |
589 changed_after: timeAgo(MS_PER_WEEK), | |
590 email1: myUsername, | |
591 email1_type: "equals", | |
592 email1_assigned_to: 1, | |
593 email1_reporter: 1, | |
594 email1_cc: 1}); | |
552 }; | 595 }; |
553 | 596 |
554 var refreshCommand = { | 597 var refreshCommand = { |
555 name: "refresh-dashboard", | 598 name: "refresh-dashboard", |
556 execute: function execute() { | 599 execute: function execute() { |