Skip to content

Commit

Permalink
fix imports
Browse files Browse the repository at this point in the history
  • Loading branch information
folland87 committed Dec 6, 2024
1 parent d47ba1a commit 8d9eb39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/jobs/sirene/fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export const fetchSirenDataById = async (sirenId) => {
}
};

const fetchSiretDataById = async (siretId) => {
export const fetchSiretDataById = async (siretId) => {
const structure = {
siren: siretId.slice(0, 9),
siret: siretId,
Expand Down
13 changes: 7 additions & 6 deletions src/jobs/sirene/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ export default async function monitorSiren(job) {
updatesInSirene.some((update) => update.siret === siret),
);
console.log(stockToBeUpdated?.length, stockToBeUpdated);
const stockUpdates = stockToBeUpdated.map((stockElement) => {
const siretData = fetchSiretDataById(stockElement.siret);
const sireneData = fetchSirenDataById(stockElement.siren);
return {
const stockUpdates = [];
for (const stockElement of stockToBeUpdated) {
const siretData = await fetchSiretDataById(stockElement.siret);
const sireneData = await fetchSirenDataById(stockElement.siren);
stockUpdates.push({
...stockElement,
siretData,
sireneData,
};
});
});
}

const ok = await db.collection("_siren").insertMany(stockUpdates);
return { status: ok ? "success" : "failed", lastExecution: now };
Expand Down

0 comments on commit 8d9eb39

Please sign in to comment.