Commit a49abbb8 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

ui: Improve recurrent api calls throttling

do not trigger faster recurrent intervals when api endpoint does not support
incremental updates (changes-since parameter).
parent bdfcc33d
......@@ -399,7 +399,7 @@
},
get_fetcher: function(interval, increase, fast, increase_after_calls,
max, initial_call, params) {
max, initial_call, params, fetcher_id) {
var fetch_params = params || {};
var handler_options = {};
......@@ -409,7 +409,7 @@
handler_options.fast = fast;
handler_options.increase_after_calls = increase_after_calls;
handler_options.max= max;
handler_options.id = "collection id";
handler_options.id = fetcher_id || "collection";
var last_ajax = undefined;
var callback = _.bind(function() {
......@@ -2481,6 +2481,7 @@
model: models.Quota,
api_type: 'accounts',
path: 'quotas',
supportIncUpdates: false,
parse: function(resp) {
filtered = _.map(resp.system, function(value, key) {
var available = (value.limit - value.usage) || 0;
......
......@@ -124,7 +124,10 @@
options.url = getUrl(urlobject, options, method) || urlError();
if (urlobject && urlobject.supportIncUpdates) {
options.url = options.refresh ? options.url : setChangesSince(options.url, type);
if (!options.refresh) {
options.url = setChangesSince(options.url, type);
options._detect_change_by_response_code = true;
}
}
if (!options.refresh && options.cache === undefined) {
options.cache = true;
......@@ -261,7 +264,8 @@
return;
}
if (["beforeSend", "complete"].indexOf(cb_type) == -1 && this.is_recurrent) {
if (["beforeSend", "complete"].indexOf(cb_type) == -1 &&
this._detect_change_by_response_code) {
// trigger event to notify that a recurrent event
// has returned status other than notmodified
snf.api.trigger("change:recurrent");
......
......@@ -763,7 +763,8 @@
snf.config.update_interval_increase_after_calls || 4,
snf.config.update_interval_max || 20000,
true,
{is_recurrent: true}];
{is_recurrent: true},
key];
var fetcher = collection.get_fetcher.apply(collection, _.clone(fetcher_params));
this._fetchers[key] = fetcher;
collection.fetch();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment