88 ElasticFicheTravailEmploi ,
99 ExportEsStatus ,
1010 FicheTravailEmploiDoc ,
11- InfographicTemplateDoc ,
11+ InfographicTemplateDoc
1212} from "@socialgouv/cdtn-types" ;
1313import { logger } from "@shared/utils" ;
1414import { SOURCES } from "@socialgouv/cdtn-utils" ;
@@ -18,21 +18,22 @@ import { buildThemes } from "./themes/buildThemes";
1818import {
1919 getDocumentBySource ,
2020 getDocumentBySourceWithRelation ,
21- } from "./common/fetchCdtnAdminDocuments" ;
21+ getGlossary ,
22+ populateRelatedDocuments
23+ } from "./common" ;
2224import { splitArticle } from "./fichesTravailSplitter" ;
2325import {
2426 fetchContributionDocumentToPublish ,
25- generateContributions ,
27+ generateContributions
2628} from "./contributions" ;
2729import { generateAgreements } from "./agreements" ;
2830import { fetchThemes } from "./themes/fetchThemes" ;
2931import { updateExportEsStatusWithDocumentsCount } from "./exportStatus/updateExportEsStatusWithDocumentsCount" ;
3032import { generatePrequalified } from "./prequalified" ;
3133import { generateEditorialContents } from "./informations/generate" ;
32- import { populateRelatedDocuments } from "./common/populateRelatedDocuments" ;
3334import { mergeRelatedDocumentsToEditorialContents } from "./informations/mergeRelatedDocumentsToEditorialContents" ;
3435import { updateExportStatuses } from "./documents/updateExportStatuses" ;
35- import { getGlossary } from "./common/fetchGlossary " ;
36+ import { generateInfographics } from "./infographics " ;
3637
3738/**
3839 * Find duplicate slugs
@@ -49,7 +50,7 @@ export async function getDuplicateSlugs(allDocuments: any) {
4950 return slugs
5051 . map ( ( slug : string ) => ( {
5152 count : slugs . filter ( ( s : string ) => slug === s ) . length ,
52- slug,
53+ slug
5354 } ) )
5455 . filter ( ( { count } : any ) => count > 1 )
5556 . reduce (
@@ -68,8 +69,9 @@ export async function cdtnDocumentsGen(
6869
6970 const getBreadcrumbs = buildGetBreadcrumbs ( themes ) ;
7071
71- const contributionsToPublish =
72- await fetchContributionDocumentToPublish ( isProd ) ;
72+ const contributionsToPublish = await fetchContributionDocumentToPublish (
73+ isProd
74+ ) ;
7375
7476 logger . info ( "=== Courriers ===" ) ;
7577 const modelesDeCourriers = await getDocumentBySource (
@@ -78,15 +80,15 @@ export async function cdtnDocumentsGen(
7880 ) ;
7981 documentsCount = {
8082 ...documentsCount ,
81- [ SOURCES . LETTERS ] : modelesDeCourriers . length ,
83+ [ SOURCES . LETTERS ] : modelesDeCourriers . length
8284 } ;
8385 await updateDocs ( SOURCES . LETTERS , modelesDeCourriers ) ;
8486
8587 logger . info ( "=== Outils ===" ) ;
8688 const tools = await getDocumentBySource ( SOURCES . TOOLS , getBreadcrumbs ) ;
8789 documentsCount = {
8890 ...documentsCount ,
89- [ SOURCES . TOOLS ] : tools . length ,
91+ [ SOURCES . TOOLS ] : tools . length
9092 } ;
9193 await updateDocs ( SOURCES . TOOLS , tools ) ;
9294
@@ -97,7 +99,7 @@ export async function cdtnDocumentsGen(
9799 ) ;
98100 documentsCount = {
99101 ...documentsCount ,
100- [ SOURCES . EXTERNALS ] : externalTools . length ,
102+ [ SOURCES . EXTERNALS ] : externalTools . length
101103 } ;
102104 await updateDocs ( SOURCES . EXTERNALS , externalTools ) ;
103105
@@ -109,7 +111,7 @@ export async function cdtnDocumentsGen(
109111 ) ;
110112 documentsCount = {
111113 ...documentsCount ,
112- [ SOURCES . THEMATIC_FILES ] : dossiers . length ,
114+ [ SOURCES . THEMATIC_FILES ] : dossiers . length
113115 } ;
114116
115117 await updateDocs ( SOURCES . THEMATIC_FILES , dossiers ) ;
@@ -148,7 +150,7 @@ export async function cdtnDocumentsGen(
148150
149151 documentsCount = {
150152 ...documentsCount ,
151- [ SOURCES . CONTRIBUTIONS ] : generatedContributions . length ,
153+ [ SOURCES . CONTRIBUTIONS ] : generatedContributions . length
152154 } ;
153155
154156 await updateDocs ( SOURCES . CONTRIBUTIONS , generatedContributions ) ;
@@ -161,7 +163,7 @@ export async function cdtnDocumentsGen(
161163
162164 documentsCount = {
163165 ...documentsCount ,
164- [ SOURCES . CCN ] : agreementsDocs . length ,
166+ [ SOURCES . CCN ] : agreementsDocs . length
165167 } ;
166168
167169 await updateDocs ( SOURCES . CCN , agreementsDocs ) ;
@@ -171,7 +173,7 @@ export async function cdtnDocumentsGen(
171173
172174 documentsCount = {
173175 ...documentsCount ,
174- [ SOURCES . SHEET_SP ] : fichesSp . length ,
176+ [ SOURCES . SHEET_SP ] : fichesSp . length
175177 } ;
176178 await updateDocs ( SOURCES . SHEET_SP , fichesSp ) ;
177179
@@ -188,17 +190,17 @@ export async function cdtnDocumentsGen(
188190 html : section . htmlWithGlossary ,
189191 anchor : section . anchor ,
190192 references : section . references ,
191- title : section . title ,
193+ title : section . title
192194 } ) ) ,
193- source : SOURCES . SHEET_MT_PAGE ,
195+ source : SOURCES . SHEET_MT_PAGE
194196 } )
195197 ) ;
196198 logger . info (
197199 `Mapped ${ fichesMTWithGlossary . length } fiches travail with glossary`
198200 ) ;
199201 documentsCount = {
200202 ...documentsCount ,
201- [ SOURCES . SHEET_MT_PAGE ] : fichesMTWithGlossary . length ,
203+ [ SOURCES . SHEET_MT_PAGE ] : fichesMTWithGlossary . length
202204 } ;
203205
204206 await updateDocs ( SOURCES . SHEET_MT_PAGE , fichesMTWithGlossary ) ;
@@ -214,20 +216,20 @@ export async function cdtnDocumentsGen(
214216 return {
215217 ...fiche ,
216218 breadcrumbs,
217- source : SOURCES . SHEET_MT ,
219+ source : SOURCES . SHEET_MT
218220 } ;
219221 } ) ;
220222 documentsCount = {
221223 ...documentsCount ,
222- [ SOURCES . SHEET_MT ] : splittedFichesMt . length ,
224+ [ SOURCES . SHEET_MT ] : splittedFichesMt . length
223225 } ;
224226 await updateDocs ( SOURCES . SHEET_MT , splittedFichesMt ) ;
225227
226228 logger . info ( "=== Themes ===" ) ;
227229 const themesDoc = buildThemes ( themes , getBreadcrumbs ) ;
228230 documentsCount = {
229231 ...documentsCount ,
230- [ SOURCES . THEMES ] : themesDoc . length ,
232+ [ SOURCES . THEMES ] : themesDoc . length
231233 } ;
232234
233235 await updateDocs ( SOURCES . THEMES , themesDoc ) ;
@@ -248,55 +250,56 @@ export async function cdtnDocumentsGen(
248250 ) ;
249251 return {
250252 ...ref ,
251- description : foundContrib ?. description ,
253+ description : foundContrib ?. description
252254 } ;
253255 }
254256 return ref ;
255- } ) ,
257+ } )
256258 } ) ) ;
257259 documentsCount = {
258260 ...documentsCount ,
259- [ SOURCES . HIGHLIGHTS ] : highlightsWithContrib . length ,
261+ [ SOURCES . HIGHLIGHTS ] : highlightsWithContrib . length
260262 } ;
261263 await updateDocs ( SOURCES . HIGHLIGHTS , highlightsWithContrib ) ;
262264
263265 logger . info ( "=== PreQualified Request ===" ) ;
264266 const prequalified = await generatePrequalified ( getBreadcrumbs ) ;
265267 documentsCount = {
266268 ...documentsCount ,
267- [ SOURCES . PREQUALIFIED ] : prequalified . length ,
269+ [ SOURCES . PREQUALIFIED ] : prequalified . length
268270 } ;
269271 await updateDocs ( SOURCES . PREQUALIFIED , prequalified ) ;
270272
271273 logger . info ( "=== glossary ===" ) ;
272274 const glossaryTerms = await getGlossary ( ) ;
273275 documentsCount = {
274276 ...documentsCount ,
275- [ SOURCES . GLOSSARY ] : glossaryTerms . length ,
277+ [ SOURCES . GLOSSARY ] : glossaryTerms . length
276278 } ;
277279 await updateDocs ( SOURCES . GLOSSARY , [
278280 {
279281 data : glossaryTerms ,
280- source : SOURCES . GLOSSARY ,
281- } ,
282+ source : SOURCES . GLOSSARY
283+ }
282284 ] ) ;
283285
284286 logger . info ( "=== Code du travail ===" ) ;
285287 const cdtDoc = await getDocumentBySource ( SOURCES . CDT ) ;
286288 documentsCount = {
287289 ...documentsCount ,
288- [ SOURCES . CDT ] : cdtDoc . length ,
290+ [ SOURCES . CDT ] : cdtDoc . length
289291 } ;
290292 await updateDocs ( SOURCES . CDT , cdtDoc ) ;
291293
292294 logger . info ( "=== Infographies ===" ) ;
293- const infographics = await getDocumentBySource < InfographicTemplateDoc > (
295+ const infographicDocs = await getDocumentBySource < InfographicTemplateDoc > (
294296 SOURCES . INFOGRAPHICS ,
295297 getBreadcrumbs
296298 ) ;
299+ const infographics = await generateInfographics ( infographicDocs ) ;
297300 documentsCount = {
298301 ...documentsCount ,
299- [ SOURCES . INFOGRAPHICS ] : infographics . length ,
302+ [ SOURCES . INFOGRAPHICS ] : infographics . length
300303 } ;
301304 await updateDocs ( SOURCES . INFOGRAPHICS , infographics ) ;
302305
@@ -307,11 +310,11 @@ export async function cdtnDocumentsGen(
307310 ) ;
308311 const {
309312 documents : editorialContents ,
310- relatedIdsDocuments : relatedIdsEditorialDocuments ,
313+ relatedIdsDocuments : relatedIdsEditorialDocuments
311314 } = generateEditorialContents ( documents , infographics ) ;
312315 documentsCount = {
313316 ...documentsCount ,
314- [ SOURCES . EDITORIAL_CONTENT ] : editorialContents . length ,
317+ [ SOURCES . EDITORIAL_CONTENT ] : editorialContents . length
315318 } ;
316319
317320 logger . info ( "=== Merge Related Documents ===" ) ;
@@ -327,7 +330,7 @@ export async function cdtnDocumentsGen(
327330 ...fichesMTWithGlossary ,
328331 ...splittedFichesMt ,
329332 ...highlightsWithContrib ,
330- ...cdtDoc ,
333+ ...cdtDoc
331334 ] ;
332335
333336 const relatedDocuments = populateRelatedDocuments (
@@ -348,7 +351,7 @@ export async function cdtnDocumentsGen(
348351 logger . info ( "=== Save the documents length ===" ) ;
349352 documentsCount = {
350353 ...documentsCount ,
351- total : Object . values ( documentsCount ) . reduce ( ( a : any , b : any ) => a + b , 0 ) ,
354+ total : Object . values ( documentsCount ) . reduce ( ( a : any , b : any ) => a + b , 0 )
352355 } ;
353356 await updateExportEsStatusWithDocumentsCount (
354357 documentsCount as ExportEsStatus [ "documentsCount" ]
0 commit comments