summaryrefslogtreecommitdiffstats
path: root/extensions/MozReview/web
diff options
context:
space:
mode:
authorMark Côté <mcote@alumni.uwaterloo.ca>2015-05-05 02:29:09 +0200
committerMark Côté <mcote@alumni.uwaterloo.ca>2015-05-05 17:23:39 +0200
commit63b0ecb066a2bfde2828d77c0c414c57d4b7b1ce (patch)
treeb081a1be30a94ba88a1bcf526d73e87210a27f34 /extensions/MozReview/web
parent27db7bb9aabe7a411d701ffbd9989e1ef11a9651 (diff)
downloadbugzilla-63b0ecb066a2bfde2828d77c0c414c57d4b7b1ce.tar.gz
bugzilla-63b0ecb066a2bfde2828d77c0c414c57d4b7b1ce.tar.xz
Bug 1158516 - Fetch MozReview summaries by bug. r=glob
Instead of issuing separate calls for every MozReview request associated with a given bug, call the new MozReview summaries-by-bug API exactly once.
Diffstat (limited to 'extensions/MozReview/web')
-rw-r--r--extensions/MozReview/web/js/mozreview.js69
1 files changed, 39 insertions, 30 deletions
diff --git a/extensions/MozReview/web/js/mozreview.js b/extensions/MozReview/web/js/mozreview.js
index 2d5fdb0fa..2b9575292 100644
--- a/extensions/MozReview/web/js/mozreview.js
+++ b/extensions/MozReview/web/js/mozreview.js
@@ -50,8 +50,9 @@ MozReview.getReviewRequest = function() {
var tr = $('<tr/>');
var td = $('<td/>');
- var rrApiBaseUrl = hostUrl +
- 'api/extensions/mozreview.extension.MozReviewExtension/summary/';
+ var rrSummaryApiUrl = hostUrl +
+ 'api/extensions/mozreview.extension.MozReviewExtension/summary/?bug=' +
+ BUGZILLA.bug_id;
var rrUiBaseUrl = hostUrl + 'r/';
function rrUrl(rrId) {
@@ -104,35 +105,43 @@ MozReview.getReviewRequest = function() {
}
});
- $('.mozreview-request').each(function() {
- var tbody = $(this);
- var rrId = tbody.data('rrid');
- var url = rrApiBaseUrl + rrId + '/';
- var i;
-
- $.getJSON(url, function(data) {
- var parent = data.parent;
- tbody.append(rrRow(parent, true));
- for (i = 0; i < data.children.length; i++) {
- tbody.append(rrRow(data.children[i], false));
- }
- tbody.find('.mozreview-loading-row').addClass('bz_default_hidden');
- }).fail(function(jqXHR, textStatus, errorThrown) {
- tbody.find('.mozreview-loading-row').addClass('bz_default_hidden');
- tbody.find('.mozreview-load-error-rrid').text(rrId);
- var errRow = tbody.find('.mozreview-loading-error-row');
- var errStr;
- if (jqXHR.responseJSON && jqXHR.responseJSON.err &&
- jqXHR.responseJSON.err.msg) {
- errStr = jqXHR.responseJSON.err.msg;
- } else if (errorThrown) {
- errStr = errorThrown;
- } else {
- errStr = 'unknown';
+ var tbody = $('tbody.mozreview-request');
+
+ function displayLoadError(errStr) {
+ var errRow = tbody.find('.mozreview-loading-error-row');
+ errRow.find('.mozreview-load-error-string').text(errStr);
+ errRow.removeClass('bz_default_hidden');
+ }
+
+ $.getJSON(rrSummaryApiUrl, function(data) {
+ var family, parent, i, j;
+
+ if (data.review_request_summaries.length === 0) {
+ displayLoadError('none returned from server');
+ } else {
+ for (i = 0; i < data.review_request_summaries.length; i++) {
+ family = data.review_request_summaries[i];
+ parent = family.parent;
+ tbody.append(rrRow(parent, true));
+ for (j = 0; j < family.children.length; j++) {
+ tbody.append(rrRow(family.children[j], false));
+ }
}
- errRow.find('.mozreview-load-error-string').text(errStr);
- errRow.removeClass('bz_default_hidden');
- });
+ }
+
+ tbody.find('.mozreview-loading-row').addClass('bz_default_hidden');
+ }).fail(function(jqXHR, textStatus, errorThrown) {
+ var errStr;
+ if (jqXHR.responseJSON && jqXHR.responseJSON.err &&
+ jqXHR.responseJSON.err.msg) {
+ errStr = jqXHR.responseJSON.err.msg;
+ } else if (errorThrown) {
+ errStr = errorThrown;
+ } else {
+ errStr = 'unknown';
+ }
+ displayLoadError(errStr);
+ tbody.find('.mozreview-loading-row').addClass('bz_default_hidden');
});
};