From af81b4174d0117dc5896368b569219b753c612bc Mon Sep 17 00:00:00 2001 From: ImJustChew Date: Thu, 25 Jul 2024 02:36:42 +0800 Subject: [PATCH] feat: finalized scrape cousres pipeline --- runners/update-courses.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/runners/update-courses.ts b/runners/update-courses.ts index 6008bc5b..0c52d696 100644 --- a/runners/update-courses.ts +++ b/runners/update-courses.ts @@ -1,6 +1,8 @@ import schedule from 'node-schedule'; -const job = schedule.scheduleJob('8 * * * *', async () => { +// Run every day at 8:00 AM +// 8 AM (GMT+8) = 0 AM (GMT) +const job = schedule.scheduleJob('0 0 * * *', async () => { try { console.log('syncing courses begin uwu') const res = await fetch('http://localhost:8080/api/scrape-archived-courses?semester=11310', { @@ -9,6 +11,18 @@ const job = schedule.scheduleJob('8 * * * *', async () => { 'Authorization': `Bearer ${process.env.CRON_SECRET}` } }); + const res2 = await fetch('http://localhost:8080/api/scrape-syllabus?semester=11310', { + method: 'GET', + headers: { + 'Authorization': `Bearer ${process.env.CRON_SECRET}` + } + }); + const res3 = await fetch('http://localhost:8080/api/sync-algolia?semester=11310', { + method: 'GET', + headers: { + 'Authorization': `Bearer ${process.env.CRON_SECRET}` + } + }); console.log('syncing courses end uwu') } catch (e) { console.error('error calling scrape-courses', e);