Skip to content

Commit

Permalink
fix: ajout des types manquants fiches MT + article du CDT (#1484)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-maillot authored Oct 7, 2024
1 parent 061e7da commit 9ad877b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
6 changes: 6 additions & 0 deletions shared/types/src/elastic/code-du-travail.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { LaborCodeDoc } from "../hasura";
import { DocumentElasticWithSource } from "./common";

export type ElasticLaborCodeArticle = DocumentElasticWithSource<
Omit<LaborCodeDoc, "cid">
>;
13 changes: 13 additions & 0 deletions shared/types/src/elastic/fiche-travail.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { DocumentElasticWithSource } from "./common";
import { FicheTravailEmploiDoc, Section } from "../hasura";

export type ElasticFicheTravailEmploi = DocumentElasticWithSource<
Omit<FicheTravailEmploiDoc, "sections">
> & {
sections: ElasticFicheTravailEmploiSection[];
};

export type ElasticFicheTravailEmploiSection = Omit<
Section,
"htmlWithGlossary" | "text" | "description"
>;
2 changes: 2 additions & 0 deletions shared/types/src/elastic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ export * from "./common";
export * from "./prequalified";
export * from "./tools";
export * from "./editorial-content";
export * from "./fiche-travail";
export * from "./code-du-travail";
26 changes: 14 additions & 12 deletions targets/export-elasticsearch/src/ingester/cdtnDocuments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import {
AgreementDoc,
ContributionDocumentJson,
ContributionHighlight,
DocumentElasticWithSource,
DocumentRef,
EditorialContentDoc,
ElasticFicheTravailEmploi,
ExportEsStatus,
FicheTravailEmploiDoc,
DocumentElasticWithSource,
DocumentRef,
} from "@socialgouv/cdtn-types";
import { logger } from "@shared/utils";
import { SOURCES } from "@socialgouv/cdtn-sources";
Expand Down Expand Up @@ -182,16 +183,17 @@ export async function cdtnDocumentsGen(
getBreadcrumbs
);
logger.info(`Fetched ${fichesMT.length} fiches travail`);
const fichesMTWithGlossary = fichesMT.map(({ sections, ...infos }) => ({
...infos,
sections: sections.map(({ ...section }: any) => {
const html = section.htmlWithGlossary;
delete section.description;
delete section.text;
delete section.htmlWithGlossary;
return { ...section, html };
}),
}));
const fichesMTWithGlossary: ElasticFicheTravailEmploi[] = fichesMT.map(
({ sections, ...infos }): ElasticFicheTravailEmploi => ({
...infos,
sections: sections.map((section) => ({
html: section.htmlWithGlossary,
anchor: section.anchor,
references: section.references,
title: section.title,
})),
})
);
logger.info(
`Mapped ${fichesMTWithGlossary.length} fiches travail with glossary`
);
Expand Down

0 comments on commit 9ad877b

Please sign in to comment.