Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not request all schedules details at once, proceed in small batches #884

Merged
merged 5 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dispatcher/frontend-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@fortawesome/fontawesome-svg-core": "^1.2.25",
"@fortawesome/free-solid-svg-icons": "^5.11.2",
"@fortawesome/vue-fontawesome": "^0.1.8",
"axios": "^0.21.2",
"axios": "^1.6.0",
"bootstrap": "^4.4.1",
"bootstrap-vue": "^2.1.0",
"core-js": "^3.3.2",
Expand Down
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 = Constants.TASKS_LOAD_SCHEDULES_CHUNK_SIZE;
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) {
rgaudin marked this conversation as resolved.
Show resolved Hide resolved
requests.push(parent.queryAPI('get', "/schedules/" + chunk[iChunk]))
}
await Constants.getDelay(Constants.TASKS_LOAD_SCHEDULES_DELAY)
}

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

results.forEach(function (response, index) {
Expand Down
7 changes: 7 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 getDelay(milliseconds) { // retrieve a promise making a pause in milliseconds
return new Promise(resolve => setTimeout(resolve, milliseconds));
}

var DEFAULT_CPU_SHARE = 1024;

var ZIMFARM_WEBAPI = window.environ.ZIMFARM_WEBAPI || "https://api.farm.openzim.org/v1";
Expand All @@ -307,6 +311,8 @@ export default {
},
zimfarm_webapi: ZIMFARM_WEBAPI,
kiwix_download_url: window.environ.ZIMFARM_KIWIX_DOWNLOAD_URL || "https://download.kiwix.org/zim",
TASKS_LOAD_SCHEDULES_CHUNK_SIZE: parseInt(window.environ.ZIMFARM_TASKS_LOAD_SCHEDULES_CHUNK_SIZE, 10) || 5,
TASKS_LOAD_SCHEDULES_DELAY: parseInt(window.environ.ZIMFARM_TASKS_LOAD_SCHEDULES_DELAY, 10) || 100,
DEFAULT_CPU_SHARE: DEFAULT_CPU_SHARE, // used to generate docker cpu-shares
DEFAULT_FIRE_PRIORITY: 5,
DEFAULT_LIMIT: 20,
Expand Down Expand Up @@ -527,4 +533,5 @@ export default {
fromSeconds: DateTime.fromSeconds,
to_timestamp: to_timestamp,
is_ios_firefox: isFirefoxOnIOS(),
getDelay: getDelay,
};
Loading