Skip to content

Commit

Permalink
Do not request all schedules details at once, proceed in small batches
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit74 committed Dec 12, 2023
1 parent d25e0f0 commit fb56e8a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
14 changes: 11 additions & 3 deletions dispatcher/frontend-ui/src/components/PipelineTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,20 @@
},
async loadLastRuns() {
let parent = this;
parent.last_runs_loaded = false;
let schedule_names = parent.tasks.map(function (item) { return item.schedule_name; }).unique();

parent.toggleLoader("fetching last runs…");
let requests = schedule_names.map(function (schedule_name) {
return parent.queryAPI('get', "/schedules/" + schedule_name);
});
const chunkSize = 5;
let requests = []
for (let i = 0; i < schedule_names.length; i += chunkSize) {
const chunk = schedule_names.slice(i, i + chunkSize);
for (let iChunk in chunk) {
requests.push(parent.queryAPI('get', "/schedules/" + chunk[iChunk]))
}
await Constants.delay(500)
}

const results = await Promise.all(requests.map(p => p.catch(e => e)));

results.forEach(function (response, index) {
Expand Down
5 changes: 5 additions & 0 deletions dispatcher/frontend-ui/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ function get_timezone_details() {
return {tz: dt.zoneName, offset: dt.o, offsetstr: offsetstr}
}

function delay(time) {
return new Promise(resolve => setTimeout(resolve, time));
}

var DEFAULT_CPU_SHARE = 1024;

var ZIMFARM_WEBAPI = window.environ.ZIMFARM_WEBAPI || "https://api.farm.openzim.org/v1";
Expand Down Expand Up @@ -527,4 +531,5 @@ export default {
fromSeconds: DateTime.fromSeconds,
to_timestamp: to_timestamp,
is_ios_firefox: isFirefoxOnIOS(),
delay: delay,
};

0 comments on commit fb56e8a

Please sign in to comment.