Skip to content

Commit

Permalink
Merge pull request #18 from MTES-MCT/fix/missing-siren-hydration
Browse files Browse the repository at this point in the history
Correction sur l'hydratation des données SIREN
  • Loading branch information
Riron authored Apr 2, 2024
2 parents 65c9d5c + f0ecf3c commit 49f005f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/indexation/indexInsee.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,23 @@ const siretWithUniteLegaleFormatter = async (
if (!body.length) {
return [];
}

const result: ElasticBulkNonFlatPayload = [];

const chunkSize = 10_000; // Max number of SIREN to search in one request
for (let i = 0; i < body.length; i += chunkSize) {
const chunk = body.slice(i, i + chunkSize);
const chunkResult = await siretWithUniteLegaleChunkFormatter(chunk, extras);
result.push(...chunkResult);
}

return result;
};

const siretWithUniteLegaleChunkFormatter = async (
body: ElasticBulkNonFlatPayload,
extras: { sireneIndexConfig: IndexProcessConfig }
): Promise<ElasticBulkNonFlatPayload> => {
const response = await client.search({
index: sireneIndexConfig.alias,
body: {
Expand Down

0 comments on commit 49f005f

Please sign in to comment.