From f85f181bc90bce4a8fdbab57c1bda6cec21eb8e5 Mon Sep 17 00:00:00 2001 From: Martial Maillot Date: Fri, 30 Aug 2024 08:13:32 +0200 Subject: [PATCH] =?UTF-8?q?fix(recherche):=20remonter=20les=20pr=C3=A9-qua?= =?UTF-8?q?lifi=C3=A9s=20dans=20la=20recherche=20(#6082)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/recherche.tsx | 3 +-- .../__snapshots__/service.test.ts.snap | 24 +++++++++---------- .../src/api/modules/search/service/search.ts | 6 ++--- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/packages/code-du-travail-frontend/pages/recherche.tsx b/packages/code-du-travail-frontend/pages/recherche.tsx index b754429685..af8d5303d2 100644 --- a/packages/code-du-travail-frontend/pages/recherche.tsx +++ b/packages/code-du-travail-frontend/pages/recherche.tsx @@ -15,7 +15,6 @@ import styled from "styled-components"; import Metas from "../src/common/Metas"; import { ConventionModal } from "../src/conventions/SearchModal"; import { Layout } from "../src/layout/Layout"; -import { fetchSearchResults } from "../src/search/search.service"; import SearchBar from "../src/search/SearchBar"; import { SearchResults } from "../src/search/SearchResults"; import { useRouter } from "next/router"; @@ -104,7 +103,7 @@ const SearchPage = ({ export const getServerSideProps: GetServerSideProps = async (context) => { const q = (context.query.q as string) ?? ""; - const items = await searchWithQuery(q, true, undefined); + const items = await searchWithQuery(q, false, undefined); return { props: { items } }; }; diff --git a/packages/code-du-travail-frontend/src/api/modules/search/__tests__/__snapshots__/service.test.ts.snap b/packages/code-du-travail-frontend/src/api/modules/search/__tests__/__snapshots__/service.test.ts.snap index 57677fe392..ac6eaa5c31 100644 --- a/packages/code-du-travail-frontend/src/api/modules/search/__tests__/__snapshots__/service.test.ts.snap +++ b/packages/code-du-travail-frontend/src/api/modules/search/__tests__/__snapshots__/service.test.ts.snap @@ -4,7 +4,7 @@ exports[`Search searchWithQuery 1`] = ` { "articles": [ { - "_score": undefined, + "_score": null, "algo": "pre-qualified", "breadcrumbs": [], "cdtnId": "6638a02755", @@ -14,7 +14,7 @@ exports[`Search searchWithQuery 1`] = ` "title": "L1231-1", }, { - "_score": undefined, + "_score": null, "algo": "pre-qualified", "breadcrumbs": [], "cdtnId": "ea03713a82", @@ -24,7 +24,7 @@ exports[`Search searchWithQuery 1`] = ` "title": "L1237-1", }, { - "_score": undefined, + "_score": null, "algo": "pre-qualified", "breadcrumbs": [], "cdtnId": "4c53e81904", @@ -45,7 +45,7 @@ exports[`Search searchWithQuery 1`] = ` ], "documents": [ { - "_score": undefined, + "_score": null, "algo": "pre-qualified", "breadcrumbs": [ { @@ -66,7 +66,7 @@ exports[`Search searchWithQuery 1`] = ` "title": "Démission d'un salarié", }, { - "_score": undefined, + "_score": null, "algo": "pre-qualified", "breadcrumbs": [ { @@ -87,7 +87,7 @@ exports[`Search searchWithQuery 1`] = ` "title": "La démission", }, { - "_score": undefined, + "_score": null, "algo": "pre-qualified", "breadcrumbs": [ { @@ -108,7 +108,7 @@ exports[`Search searchWithQuery 1`] = ` "title": "Un salarié peut-il percevoir l'allocation chômage en cas de démission ?", }, { - "_score": undefined, + "_score": null, "algo": "pre-qualified", "breadcrumbs": [ { @@ -134,7 +134,7 @@ exports[`Search searchWithQuery 1`] = ` "title": "Peut-on démissionner pendant ses congés payés ?", }, { - "_score": undefined, + "_score": null, "algo": "pre-qualified", "breadcrumbs": [ { @@ -155,7 +155,7 @@ exports[`Search searchWithQuery 1`] = ` "title": "Peut-on démissionner pendant un arrêt maladie ?", }, { - "_score": undefined, + "_score": null, "algo": "pre-qualified", "breadcrumbs": [ { @@ -176,7 +176,7 @@ exports[`Search searchWithQuery 1`] = ` "title": "Peut-on démissionner pendant un congé maternité ?", }, { - "_score": undefined, + "_score": null, "algo": "pre-qualified", "breadcrumbs": [ { @@ -197,7 +197,7 @@ exports[`Search searchWithQuery 1`] = ` "title": "Peut-on démissionner pendant un congé parental ?", }, { - "_score": undefined, + "_score": null, "algo": "pre-qualified", "breadcrumbs": [ { @@ -218,7 +218,7 @@ exports[`Search searchWithQuery 1`] = ` "title": "Démission du salarié à domicile employé par un particulier", }, { - "_score": undefined, + "_score": null, "algo": "pre-qualified", "breadcrumbs": [ { diff --git a/packages/code-du-travail-frontend/src/api/modules/search/service/search.ts b/packages/code-du-travail-frontend/src/api/modules/search/service/search.ts index d847ee94bc..6fd1370bb5 100644 --- a/packages/code-du-travail-frontend/src/api/modules/search/service/search.ts +++ b/packages/code-du-travail-frontend/src/api/modules/search/service/search.ts @@ -109,19 +109,19 @@ export const searchWithQuery = async ( return { articles: articles.map(({ _score, _source }) => ({ - _score, + _score: _score ?? null, ..._source, title: _source.shortTitle ?? _source.title, })), documents: documents.map(({ _score, _source }) => ({ - _score, + _score: _score ?? null, ..._source, title: _source.shortTitle ?? _source.title, })), // we add source prop since some result might come from dedicated themes index // which has no source prop themes: themes.map(({ _score, _source }) => ({ - _score, + _score: _score ?? null, ..._source, source: SOURCES.THEMES, })),