Skip to content

Commit

Permalink
feat: LBAC-2025 optimisation payload des calls de recherche (#1159)
Browse files Browse the repository at this point in the history
* feat: route minimal data pour les formations

* feat: ok mais project plus réduit possible (cf. todo)

* feat: appel data réduites

* feat: no item no render

* feat: training detail réduit

* feat: export path

* feat: niveau intermédiaire loadedItemDetail

* feat: refactor

* fix: missing param

* feat: ajout de route

* fix: last missing param

* feat: temporary

* feat: réplication sur v2

* feat: back ok pour jobs

* feat: récupération plus de data nécessaires pour front

* feat: matchas OK

* feat: ok pour les lbacompanies

* fix: syntaxe switch

* feat: cleaning

* fix: some typing fixed

* feat: unused :)

* feat: update doc
  • Loading branch information
alanlr authored Apr 4, 2024
1 parent 25b223d commit 0f6d0ca
Show file tree
Hide file tree
Showing 33 changed files with 2,832 additions and 1,260 deletions.
2 changes: 2 additions & 0 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ fileignoreconfig:
checksum: cdeae2ef94431bbe8fd1bb0f1bc0c007c938c1a1d4513316cc44cb966b7f4268
- filename: ui/components/ItemDetail/ItemDetail.tsx
checksum: 1fcc0442306f83b5e45bf7da67304527598d7749b9e2642c6d4628d3b4f15a9c
- filename: ui/components/ItemDetail/loadedItemDetail.tsx
checksum: 9db6a64f202979b07251fd40445961d8db03bdb18b6668f9813bdbdf0d56aa65
- filename: ui/components/Ressources/conseilsEtAstuces.tsx
checksum: b9f16607c1fb319c2940223e7e9ce5acc48b8b5a5b519e2bb79210e3f0feaf17
- filename: ui/components/Ressources/misesEnSituation.tsx
Expand Down
37 changes: 36 additions & 1 deletion server/src/http/controllers/formations.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default (server: Server) => {
async (req, res) => {
const { referer } = req.headers
const { romes, romeDomain, caller, latitude, longitude, radius, diploma, options } = req.query
const result = await getFormationsQuery({ romes, longitude, latitude, radius, diploma, romeDomain, caller, options, referer })
const result = await getFormationsQuery({ romes, longitude, latitude, radius, diploma, romeDomain, caller, options, referer, isMinimalData: false })

if ("error" in result) {
if (result.error === "wrong_parameters") {
Expand All @@ -47,6 +47,41 @@ export default (server: Server) => {
}
)

server.get(
"/v1/formations/min",
{
schema: zRoutes.get["/v1/formations/min"],
config,
// TODO: AttachValidation Error ?
},
async (req, res) => {
const { referer } = req.headers
const { romes, romeDomain, caller, latitude, longitude, radius, diploma, options } = req.query
const result = await getFormationsQuery({ romes, longitude, latitude, radius, diploma, romeDomain, caller, options, referer, isMinimalData: true })

if ("error" in result) {
if (result.error === "wrong_parameters") {
res.status(400)
} else {
res.status(500)
}

return res.send(result)
}

if (caller && "results" in result) {
trackApiCall({
caller: caller,
api_path: "formationV1min",
training_count: result.results?.length,
result_count: result.results?.length,
response: "OK",
})
}
return res.send(result)
}
)

server.get(
"/v1/formations/formation/:id",
{
Expand Down
39 changes: 37 additions & 2 deletions server/src/http/controllers/formations.controller.v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default (server: Server) => {
async (req, res) => {
const { referer } = req.headers
const { romes, romeDomain, caller, latitude, longitude, radius, diploma, options } = req.query
const result = await getFormationsQuery({ romes, longitude, latitude, radius, diploma, romeDomain, caller, options, referer })
const result = await getFormationsQuery({ romes, longitude, latitude, radius, diploma, romeDomain, caller, options, referer, isMinimalData: false })

if ("error" in result) {
if (result.error === "wrong_parameters") {
Expand All @@ -37,7 +37,42 @@ export default (server: Server) => {
if (caller && "results" in result) {
trackApiCall({
caller: caller,
api_path: "formationV1",
api_path: "formationV2",
training_count: result.results?.length,
result_count: result.results?.length,
response: "OK",
})
}
return res.send(result)
}
)

server.get(
"/formations/min",
{
schema: zRoutes.get["/formations/min"],
config,
// TODO: AttachValidation Error ?
},
async (req, res) => {
const { referer } = req.headers
const { romes, romeDomain, caller, latitude, longitude, radius, diploma, options } = req.query
const result = await getFormationsQuery({ romes, longitude, latitude, radius, diploma, romeDomain, caller, options, referer, isMinimalData: true })

if ("error" in result) {
if (result.error === "wrong_parameters") {
res.status(400)
} else {
res.status(500)
}

return res.send(result)
}

if (caller && "results" in result) {
trackApiCall({
caller: caller,
api_path: "formationV2min",
training_count: result.results?.length,
result_count: result.results?.length,
response: "OK",
Expand Down
25 changes: 24 additions & 1 deletion server/src/http/controllers/jobs.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,30 @@ export default (server: Server) => {
async (req, res) => {
const { referer } = req.headers
const { romes, rncp, caller, latitude, longitude, radius, insee, sources, diploma, opco, opcoUrl } = req.query
const result = await getJobsQuery({ romes, rncp, caller, referer, latitude, longitude, radius, insee, sources, diploma, opco, opcoUrl })
const result = await getJobsQuery({ romes, rncp, caller, referer, latitude, longitude, radius, insee, sources, diploma, opco, opcoUrl, isMinimalData: false })

if ("error" in result) {
return res.status(500).send(result)
}

if ("matchas" in result && result.matchas) {
const { matchas } = result
await incrementLbaJobsViewCount(matchas)
}

return res.status(200).send(result)
}
)
server.get(
"/v1/jobs/min",
{
schema: zRoutes.get["/v1/jobs/min"],
config,
},
async (req, res) => {
const { referer } = req.headers
const { romes, rncp, caller, latitude, longitude, radius, insee, sources, diploma, opco, opcoUrl } = req.query
const result = await getJobsQuery({ romes, rncp, caller, referer, latitude, longitude, radius, insee, sources, diploma, opco, opcoUrl, isMinimalData: true })

if ("error" in result) {
return res.status(500).send(result)
Expand Down
26 changes: 25 additions & 1 deletion server/src/http/controllers/jobs.controller.v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,31 @@ export default (server: Server) => {
async (req, res) => {
const { referer } = req.headers
const { romes, rncp, caller, latitude, longitude, radius, insee, sources, diploma, opco, opcoUrl } = req.query
const result = await getJobsQuery({ romes, rncp, caller, referer, latitude, longitude, radius, insee, sources, diploma, opco, opcoUrl })
const result = await getJobsQuery({ romes, rncp, caller, referer, latitude, longitude, radius, insee, sources, diploma, opco, opcoUrl, isMinimalData: false })

if ("error" in result) {
return res.status(500).send(result)
}

if ("matchas" in result && result.matchas) {
const { matchas } = result
await incrementLbaJobsViewCount(matchas)
}

return res.status(200).send(result)
}
)

server.get(
"/jobs/min",
{
schema: zRoutes.get["/jobs/min"],
config,
},
async (req, res) => {
const { referer } = req.headers
const { romes, rncp, caller, latitude, longitude, radius, insee, sources, diploma, opco, opcoUrl } = req.query
const result = await getJobsQuery({ romes, rncp, caller, referer, latitude, longitude, radius, insee, sources, diploma, opco, opcoUrl, isMinimalData: true })

if ("error" in result) {
return res.status(500).send(result)
Expand Down
2 changes: 2 additions & 0 deletions server/src/http/controllers/jobsEtFormations.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default (server: Server) => {
options,
referer,
api: "jobEtFormationV1",
isMinimalData: false,
})
: null,
hasSomeApiTag
Expand All @@ -82,6 +83,7 @@ export default (server: Server) => {
opco,
opcoUrl,
api: "jobEtFormationV1",
isMinimalData: false,
})
: null,
])
Expand Down
2 changes: 2 additions & 0 deletions server/src/http/controllers/jobsEtFormations.controller.v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default (server: Server) => {
options,
referer,
api: "jobEtFormationV1",
isMinimalData: false,
})
: null,
hasSomeApiTag
Expand All @@ -81,6 +82,7 @@ export default (server: Server) => {
opco,
opcoUrl,
api: "jobEtFormationV1",
isMinimalData: false,
})
: null,
])
Expand Down
Loading

0 comments on commit 0f6d0ca

Please sign in to comment.