Skip to content

Commit

Permalink
fix headers
Browse files Browse the repository at this point in the history
  • Loading branch information
folland87 committed Dec 6, 2024
1 parent 27b7c09 commit bf81ca7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/jobs/sirene/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
};
}

0 comments on commit bf81ca7

Please sign in to comment.