Skip to content

Commit

Permalink
Merge pull request #19 from MTES-MCT/fix/headers-siret
Browse files Browse the repository at this point in the history
Fix headers after 3.11 release
  • Loading branch information
Riron authored Apr 3, 2024
2 parents 49f005f + 4e590dd commit bbfad24
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
13 changes: 9 additions & 4 deletions src/commands/__tests__/index.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe("Perform indexation", () => {
throw new Error(`${r.warnings}`);
}
expect(r.body.hits.hits).toBeInstanceOf(Array);
expect(r.body.hits.total.value).toEqual(297);
expect(r.body.hits.total.value).toEqual(299);
expect(r.body.hits.hits).toEqual(
expect.arrayContaining([
expect.objectContaining({
Expand All @@ -114,16 +114,18 @@ describe("Perform indexation", () => {
nic: "00010",
siret: "00541034500010",
statutDiffusionEtablissement: "O",
dateCreationEtablissement: "",
dateCreationEtablissement: "1900-01-01",
trancheEffectifsEtablissement: "",
anneeEffectifsEtablissement: "",
activitePrincipaleRegistreMetiersEtablissement: "",
dateDernierTraitementEtablissement: "",
dateDernierTraitementEtablissement: "2024-03-22T15:40:57",
etablissementSiege: "true",
nombrePeriodesEtablissement: "1",
nombrePeriodesEtablissement: "2",
complementAdresseEtablissement: "",
numeroVoieEtablissement: "",
indiceRepetitionEtablissement: "",
dernierNumeroVoieEtablissement: "",
indiceRepetitionDernierNumeroVoieEtablissement: "",
typeVoieEtablissement: "RTE",
libelleVoieEtablissement: "DE DOULLENS",
codePostalEtablissement: "80100",
Expand All @@ -135,6 +137,9 @@ describe("Perform indexation", () => {
libelleCedexEtablissement: "",
codePaysEtrangerEtablissement: "",
libellePaysEtrangerEtablissement: "",
identifiantAdresseEtablissement: "",
coordonneeLambertAbscisseEtablissement: "",
coordonneeLambertOrdonneeEtablissement: "",
complementAdresse2Etablissement: "",
numeroVoie2Etablissement: "",
indiceRepetition2Etablissement: "",
Expand Down
4 changes: 1 addition & 3 deletions src/indexation/elasticSearch.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,15 +379,13 @@ export const streamReadAndIndex = async (
indexConfig: IndexProcessConfig,
isReleaseIndexation = true
): Promise<string> => {
const headers = indexConfig.headers;
// stop parsing CSV after MAX_ROWS
const maxRows = parseInt(process.env.MAX_ROWS as string, 10);

const readableStream = fs.createReadStream(csvPath);
const parseCsvStream = parse({
headers,
headers: true,
ignoreEmpty: true,
discardUnmappedColumns: true,
...(maxRows && { maxRows })
})
.transform((data, callback) => {
Expand Down
5 changes: 5 additions & 0 deletions src/indexation/indexInsee.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ export const siretIndexConfig: IndexProcessConfig = {
"complementAdresseEtablissement",
"numeroVoieEtablissement",
"indiceRepetitionEtablissement",
"dernierNumeroVoieEtablissement",
"indiceRepetitionDernierNumeroVoieEtablissement",
"typeVoieEtablissement",
"libelleVoieEtablissement",
"codePostalEtablissement",
Expand All @@ -261,6 +263,9 @@ export const siretIndexConfig: IndexProcessConfig = {
"libelleCedexEtablissement",
"codePaysEtrangerEtablissement",
"libellePaysEtrangerEtablissement",
"identifiantAdresseEtablissement",
"coordonneeLambertAbscisseEtablissement",
"coordonneeLambertOrdonneeEtablissement",
"complementAdresse2Etablissement",
"numeroVoie2Etablissement",
"indiceRepetition2Etablissement",
Expand Down
Binary file modified tests/fixtures/StockEtablissement_utf8_sample.zip
Binary file not shown.

0 comments on commit bbfad24

Please sign in to comment.