From 33d5a2da854c31efbbc48dc1e2ecba5242931053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Auricoste?= Date: Mon, 25 Nov 2024 10:42:55 +0100 Subject: [PATCH] fix(lbac-2114): fix workplace_address_label, ajout created_at (#1663) --- .../__snapshots__/importRHAlternance.test.ts.snap | 2 +- server/src/jobs/offrePartenaire/importRHAlternance.ts | 5 +++-- server/src/jobs/offrePartenaire/rawToComputedJobsPartners.ts | 2 ++ shared/models/rawRHAlternance.model.ts | 2 ++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/server/src/jobs/offrePartenaire/__snapshots__/importRHAlternance.test.ts.snap b/server/src/jobs/offrePartenaire/__snapshots__/importRHAlternance.test.ts.snap index 4abb50fec4..191f63e4fa 100644 --- a/server/src/jobs/offrePartenaire/__snapshots__/importRHAlternance.test.ts.snap +++ b/server/src/jobs/offrePartenaire/__snapshots__/importRHAlternance.test.ts.snap @@ -20,7 +20,7 @@ Infos complémentaires : Nous vous proposons :

Un poste en alternance ouv "partner_job_id": "913079004", "partner_label": "RH Alternance", "validated": false, - "workplace_address_label": "TOURLAVILLE 420 RUE DE LA PYROTECHNIE 50100 CHERBOURG-EN-COTENTIN", + "workplace_address_label": "34280 La Grande-Motte", "workplace_name": "GRAND LARGE YACHTING", "workplace_siret": "44537545400037", "workplace_website": "https://rhalternance.com/companies/grand-large-yachting-mediterranee", diff --git a/server/src/jobs/offrePartenaire/importRHAlternance.ts b/server/src/jobs/offrePartenaire/importRHAlternance.ts index 69e4b1c4cf..494ce1f10f 100644 --- a/server/src/jobs/offrePartenaire/importRHAlternance.ts +++ b/server/src/jobs/offrePartenaire/importRHAlternance.ts @@ -85,7 +85,6 @@ export const rawRhAlternanceToComputedMapper = (now: Date) => ({ jobCode, - companyAddress, companyName, companySiret, companyUrl, @@ -94,6 +93,8 @@ export const rawRhAlternanceToComputedMapper = jobSubmitDateTime, jobType, jobUrl, + jobCity, + jobPostalCode, }: IRawRHAlternance["job"]): IComputedJobsPartners => { const offer_creation = jobSubmitDateTime ? dayjs.tz(jobSubmitDateTime).toDate() : now const isValid: boolean = jobType === "Alternance" @@ -114,7 +115,7 @@ export const rawRhAlternanceToComputedMapper = workplace_siret: companySiret, workplace_name: companyName, workplace_website: companyUrl, - workplace_address_label: companyAddress, + workplace_address_label: [jobPostalCode, jobCity].flatMap((x) => (x ? [x] : [])).join(" ") || null, apply_url: jobUrl, errors: [], validated: false, diff --git a/server/src/jobs/offrePartenaire/rawToComputedJobsPartners.ts b/server/src/jobs/offrePartenaire/rawToComputedJobsPartners.ts index 59cbdc3760..d34362226c 100644 --- a/server/src/jobs/offrePartenaire/rawToComputedJobsPartners.ts +++ b/server/src/jobs/offrePartenaire/rawToComputedJobsPartners.ts @@ -28,6 +28,7 @@ export const rawToComputedJobsPartners = async ({ logger.info(`suppression de ${deletedCount} documents dans computed_jobs_partners pour partner_label=${partnerLabel}`) await getDbCollection("computed_jobs_partners").deleteMany({ partner_label: partnerLabel }) const counters = { total: 0, success: 0, error: 0 } + const importDate = new Date() await oleoduc( getDbCollection(collectionSource).find({}).stream(), writeData( @@ -41,6 +42,7 @@ export const rawToComputedJobsPartners = async ({ ...computedJobPartner, partner_label: partnerLabel, validated: ZJobsPartnersOfferPrivate.safeParse(computedJobPartner).success, + created_at: importDate, }) counters.success++ } catch (err) { diff --git a/shared/models/rawRHAlternance.model.ts b/shared/models/rawRHAlternance.model.ts index 59ea94bbfc..f555cc4e3e 100644 --- a/shared/models/rawRHAlternance.model.ts +++ b/shared/models/rawRHAlternance.model.ts @@ -11,6 +11,8 @@ export const ZRawRHAlternance = z.object({ jobCode: z.string(), jobType: z.string().nullish(), jobTitle: z.string().nullish(), + jobCity: z.string().nullish(), + jobPostalCode: z.string().nullish(), jobDescription: z .array( z.object({