Skip to content

Commit

Permalink
better diagoriente sorted results
Browse files Browse the repository at this point in the history
  • Loading branch information
bbohec committed Jul 11, 2024
1 parent 036cc52 commit 1a51693
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,52 +59,52 @@ describe("DiagorienteAppellationsGateway", () => {
const parallelCalls = 100;
it.each([
{
search: "Dév",
search: "faire du pain",
results: [
{
appellationLabel: "Nez",
appellationCode: "16989",
appellationLabel: "Ouvrier boulanger / Ouvrière boulangère",
appellationCode: "17407",
},
{
appellationLabel: "Dee-jay",
appellationCode: "13916",
appellationLabel: "Biscuitier / Biscuitière",
appellationCode: "11529",
},
{
appellationLabel: "Délaineur / Délaineuse",
appellationCode: "13923",
appellationLabel: "Boulanger / Boulangère",
appellationCode: "11573",
},
{
appellationLabel: "Déligneur / Déligneuse",
appellationCode: "13945",
appellationLabel: "Fourreur / Fourreuse",
appellationCode: "15157",
},
{
appellationLabel: "Déménageur / Déménageuse",
appellationCode: "13947",
appellationLabel: "Chef de rayon boulangerie",
appellationCode: "12278",
},
],
},
{
search: "ux",
search: "ux design",
results: [
{
appellationLabel: "Mareyeur / Mareyeuse",
appellationCode: "16391",
appellationLabel: "UX - user experience designer",
appellationCode: "126549",
},
{
appellationLabel: "Élagueur / Élagueuse",
appellationCode: "14608",
appellationLabel: "UI - user interface designer",
appellationCode: "126550",
},
{
appellationLabel: "Scieur / Scieuse",
appellationCode: "19323",
appellationLabel: "Designer",
appellationCode: "13991",
},
{
appellationLabel: "Liégeur / Liégeuse",
appellationCode: "16185",
appellationLabel: "Web designer",
appellationCode: "20726",
},
{
appellationLabel: "Licier / Licière",
appellationCode: "16183",
appellationLabel: "Designer / Designeuse ergonome",
appellationCode: "13998",
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class DiagorienteAppellationsGateway implements AppellationsGateway {
logger.info({ message: "searchAppellations - call" });
return this.httpClient
.searchAppellations({
queryParams: { query, nb_results: maxResults * 2, tags: ["ROME4"] },
queryParams: { query, nb_results: maxResults * 10, tags: ["ROME4"] },
headers: {
Authorization: `Bearer ${tokenData.access_token}`,
},
Expand Down Expand Up @@ -97,6 +97,7 @@ const diagorienteRawResponseToAppellationDto = (
.filter(
({ data }) => appellationCodeSchema.safeParse(data.code_ogr).success,
)
.sort((a, b) => (a.similarity <= b.similarity ? 1 : -1))
.filter((_, index) => index <= maxResults - 1)
.map(({ data }) => ({
appellationLabel: data.titre,
Expand Down

0 comments on commit 1a51693

Please sign in to comment.