From bf81ca7686ad79bb85493478346fd07098b7a31f Mon Sep 17 00:00:00 2001 From: folland87 Date: Fri, 6 Dec 2024 15:54:27 +0100 Subject: [PATCH] fix headers --- src/jobs/sirene/index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/jobs/sirene/index.js b/src/jobs/sirene/index.js index 8730e28b..073589b4 100644 --- a/src/jobs/sirene/index.js +++ b/src/jobs/sirene/index.js @@ -21,12 +21,13 @@ export default async function monitorSiren(job) { const siretStockFromPaysage = await getSiretStockFromPaysage(); - await new Promise((resolve) => setTimeout(resolve, 10000)); + await new Promise((resolve) => setTimeout(resolve, 100000)); const updatesInSirene = await fetchSireneUpdates( lastSuccessfullExecutionDate, new Date().toISOString().split("T")?.[0], ); + console.log(updatesInSirene?.length, updatesInSirene); const stockToBeUpdated = siretStockFromPaysage.filter(({ siret }) => updatesInSirene.some((update) => update.siret === siret), @@ -42,7 +43,13 @@ export default async function monitorSiren(job) { sireneData, }); } - + if (stockUpdates.length === 0) { + return { status: "success", lastExecution: now, updatesInSirene }; + } const ok = await db.collection("_siren").insertMany(stockUpdates); - return { status: ok ? "success" : "failed", lastExecution: now }; + return { + status: ok ? "success" : "failed", + lastExecution: now, + updatesInSirene, + }; }