From 715d22049ad9e49c482354246bcd1249c50b7c2b Mon Sep 17 00:00:00 2001 From: Francois Daoust Date: Tue, 18 Jun 2024 10:41:00 +0200 Subject: [PATCH] Wait 2s in between synchronization with calendar server New rate limits prevent sending too many requests to W3C servers. To stay below the 180 requests/minutes threshold, calendar synchronization now sleeps for 2s after processing a session. Note: a session issue may be linked to more than one calendar entry. These calendar entries are processed one after the other without sleeping. --- tools/commands/sync-calendar.mjs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/commands/sync-calendar.mjs b/tools/commands/sync-calendar.mjs index ae9eee2..8b4459e 100644 --- a/tools/commands/sync-calendar.mjs +++ b/tools/commands/sync-calendar.mjs @@ -3,6 +3,10 @@ import { getEnvKey } from '../lib/envkeys.mjs'; import { synchronizeSessionWithCalendar } from '../lib/calendar.mjs'; import { validateSession, validateGrid } from '../lib/validate.mjs'; +function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms, 'slept')); +} + export default async function (project, number, options) { const sessionToSynchronize = (number.trim().toLowerCase() === 'all') ? @@ -58,6 +62,9 @@ export default async function (project, number, options) { roomZoom: project.roomZoom }); console.warn(`Convert session ${session.number} to calendar entries... done`); + console.warn('Wait 2s to ease load on calendar server...'); + await sleep(2000); + console.warn('Wait 2s to ease load on calendar server... done'); } } finally {