Skip to content

Commit

Permalink
chore: réécriture de getFtJobsV2 et suppession temporaire du param di…
Browse files Browse the repository at this point in the history
…ploma de la route v2 (#1450)
  • Loading branch information
moroine authored Aug 24, 2024
1 parent 5b63bda commit 314942a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 28 deletions.
8 changes: 4 additions & 4 deletions server/src/http/controllers/jobs.controller.v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,13 @@ export default (server: Server) => {
getJobs({
romes: payload.romes,
distance: payload.radius,
niveau: payload.diploma,
niveau: null, // payload.diploma,
lat: payload.latitude,
lon: payload.longitude,
isMinimalData: false,
}),
getJobsPartnersFromDB(payload),
getFtJobsV2({ jobLimit: 150, caller: "api-apprentissage", api: zRoutes.get["/jobs/rome"].path, ...payload, insee: payload.insee ?? undefined }),
getFtJobsV2({ diploma: null, jobLimit: 150, caller: "api-apprentissage", api: zRoutes.get["/jobs/rome"].path, ...payload, insee: payload.insee ?? null }),
])

return res.send({
Expand All @@ -450,13 +450,13 @@ export default (server: Server) => {
getJobs({
romes,
distance: payload.radius,
niveau: payload.diploma,
niveau: null, // payload.diploma,
lat: payload.latitude,
lon: payload.longitude,
isMinimalData: false,
}),
getJobsPartnersFromDB({ ...payload, romes }),
getFtJobsV2({ romes, jobLimit: 150, caller: "api-apprentissage", api: zRoutes.get["/jobs/rncp"].path, ...payload, insee: payload.insee ?? undefined }),
getFtJobsV2({ diploma: null, romes, jobLimit: 150, caller: "api-apprentissage", api: zRoutes.get["/jobs/rncp"].path, ...payload, insee: payload.insee ?? null }),
])

return res.send({
Expand Down
38 changes: 16 additions & 22 deletions server/src/services/ftjob.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,43 +269,37 @@ export const getFtJobsV2 = async ({
diploma,
}: {
romes: string[]
insee?: string
insee: string | null
radius: number
jobLimit: number
caller: string
diploma: string
diploma: keyof typeof NIVEAUX_POUR_OFFRES_PE | null | undefined
api: string
}): Promise<FTResponse | { resultats: [] }> => {
}): Promise<FTResponse> => {
try {
const hasLocation = insee ? true : false

// hack : les codes insee des villes à arrondissement retournent une erreur. il faut utiliser un code insee d'arrondissement
let codeInsee = insee
if (insee === "75056") codeInsee = "75101"
else if (insee === "13055") codeInsee = "13201"
else if (insee === "69123") codeInsee = "69381"

const distance = radius || 10

const params: { codeROME: string; commune?: string; sort: number; natureContrat: string; range: string; niveauFormation?: string; insee?: string; distance?: number } = {
codeROME: romes.join(","),
commune: codeInsee,
sort: hasLocation ? 2 : 0, //sort: 0, TODO: remettre sort 0 après expérimentation CBS
sort: 0,
natureContrat: "E2,FS", //E2 -> Contrat d'Apprentissage, FS -> contrat de professionalisation
range: `0-${jobLimit - 1}`,
}

if (diploma) {
const niveauRequis = NIVEAUX_POUR_OFFRES_PE[diploma]
if (niveauRequis && niveauRequis !== "NV5") {
// pas de filtrage sur niveau requis NV5 car pas de résultats
params.niveauFormation = niveauRequis
}
if (insee) {
// hack : les codes insee des villes à arrondissement retournent une erreur. il faut utiliser un code insee d'arrondissement
let codeInsee = insee
if (insee === "75056") codeInsee = "75101"
else if (insee === "13055") codeInsee = "13201"
else if (insee === "69123") codeInsee = "69381"

params.commune = codeInsee
params.distance = distance || 10
params.sort = 2
}

if (hasLocation) {
params.insee = codeInsee
params.distance = distance
if (diploma) {
params.niveauFormation = NIVEAUX_POUR_OFFRES_PE[diploma]
}

const jobs = await searchForFtJobs(params)
Expand Down
4 changes: 2 additions & 2 deletions shared/routes/jobOpportunity.routes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NIVEAUX_POUR_LBA, OPCOS_LABEL } from "../constants/recruteur"
import { OPCOS_LABEL } from "../constants/recruteur"
import { extensions } from "../helpers/zodHelpers/zodPrimitives"
import { z } from "../helpers/zodWithOpenApi"

Expand All @@ -10,7 +10,7 @@ const ZJobOpportunityQuerystringBase = z.object({
latitude: extensions.latitude(),
longitude: extensions.longitude(),
radius: z.number().min(0).max(200).default(30),
diploma: extensions.buildEnum(NIVEAUX_POUR_LBA).default(NIVEAUX_POUR_LBA.INDIFFERENT),
// diploma: extensions.buildEnum(NIVEAUX_POUR_LBA).default(NIVEAUX_POUR_LBA.INDIFFERENT),
opco: extensions.buildEnum(OPCOS_LABEL).optional(),
opcoUrl: z.string().optional(),
})
Expand Down

0 comments on commit 314942a

Please sign in to comment.