Merge "use optimized url for zuul status"
This commit is contained in:
commit
e50c0cc6f6
@ -28,7 +28,7 @@ var pipelineNameRegex = /Build \w+ \((\w+) pipeline\)/;
|
|||||||
// The url to full status information on running jobs
|
// The url to full status information on running jobs
|
||||||
var zuulStatusURL = 'http://status.openstack.org/zuul';
|
var zuulStatusURL = 'http://status.openstack.org/zuul';
|
||||||
// The json URL to check for running jobs
|
// The json URL to check for running jobs
|
||||||
var zuulStatusJSON = 'https://zuul.openstack.org/status.json';
|
var zuulStatusJSON = 'https://zuul.openstack.org/status/change/';
|
||||||
|
|
||||||
// This is a variable to determine if we're in debugging mode, which
|
// This is a variable to determine if we're in debugging mode, which
|
||||||
// lets you globally set it to see what's going on in the flow.
|
// lets you globally set it to see what's going on in the flow.
|
||||||
@ -449,18 +449,6 @@ var ci_zuul_process_changes = function(data, change_psnum) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var ci_zuul_inner_loop = function(change_psnum) {
|
|
||||||
var current = ci_current_change();
|
|
||||||
if (current && change_psnum.indexOf(current) != 0) {
|
|
||||||
// window url is dead
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$.getJSON(zuulStatusJSON, function(data) {
|
|
||||||
ci_zuul_process_changes(data, change_psnum);
|
|
||||||
});
|
|
||||||
setTimeout(function() {ci_zuul_inner_loop(change_psnum);}, 10000);
|
|
||||||
};
|
|
||||||
|
|
||||||
var ci_zuul_for_change = function(comments) {
|
var ci_zuul_for_change = function(comments) {
|
||||||
if (!comments) {
|
if (!comments) {
|
||||||
comments = ci_parse_comments();
|
comments = ci_parse_comments();
|
||||||
@ -468,9 +456,57 @@ var ci_zuul_for_change = function(comments) {
|
|||||||
var change = ci_current_change();
|
var change = ci_current_change();
|
||||||
var psnum = ci_latest_patchset(comments);
|
var psnum = ci_latest_patchset(comments);
|
||||||
var change_psnum = change + "," + psnum;
|
var change_psnum = change + "," + psnum;
|
||||||
ci_zuul_inner_loop(change_psnum);
|
|
||||||
|
// do the loop recursively in ajax
|
||||||
|
(function poll() {
|
||||||
|
$.ajax({
|
||||||
|
url: zuulStatusJSON + change_psnum,
|
||||||
|
type: "GET",
|
||||||
|
success: function(data) {
|
||||||
|
dbg("Found zuul data for " + change_psnum, data);
|
||||||
|
ci_zuul_process_changes(data, change_psnum);
|
||||||
|
},
|
||||||
|
dataType: "json",
|
||||||
|
complete: setTimeout(function() {
|
||||||
|
// once we are done with this cycle in the loop we
|
||||||
|
// schedule ourselves again in the future with
|
||||||
|
// setTimeout. However, by the time the function
|
||||||
|
// actually gets called, other things might have
|
||||||
|
// happened, and we may want to just dump the data
|
||||||
|
// instead.
|
||||||
|
//
|
||||||
|
// the UI might have gone hidden (user was bored,
|
||||||
|
// switched to another tab / window).
|
||||||
|
//
|
||||||
|
// the user may have navigated to another review url,
|
||||||
|
// so the data returned is not relevant.
|
||||||
|
//
|
||||||
|
// both cases are recoverable when the user navigates
|
||||||
|
// around, because a new "thread" gets started on
|
||||||
|
// ci_page_load.
|
||||||
|
//
|
||||||
|
// BUG(sdague): there is the possibility that the user
|
||||||
|
// navigates away from a page and back fast enough
|
||||||
|
// that the first "thread" is not dead, and a second
|
||||||
|
// one is started. greghaynes totally said he'd come
|
||||||
|
// up with a way to fix that.
|
||||||
|
if (window.zuul_enable_status_updates == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var current = ci_current_change();
|
||||||
|
if (current && change_psnum.indexOf(current) != 0) {
|
||||||
|
// window url is dead, so don't schedule any more future
|
||||||
|
// updates for this url.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
poll();
|
||||||
|
}, 15000),
|
||||||
|
timeout: 5000
|
||||||
|
});
|
||||||
|
})();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
var input = document.createElement("input");
|
var input = document.createElement("input");
|
||||||
input.id = "toggleci";
|
input.id = "toggleci";
|
||||||
@ -501,4 +537,14 @@ window.onload = function() {
|
|||||||
subtree: true,
|
subtree: true,
|
||||||
attributes: true
|
attributes: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(document).on({
|
||||||
|
'show.visibility': function() {
|
||||||
|
window.zuul_enable_status_updates = true;
|
||||||
|
ci_page_loaded();
|
||||||
|
},
|
||||||
|
'hide.visibility': function() {
|
||||||
|
window.zuul_enable_status_updates = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user