diff --git a/src/app/rechercher/page.tsx b/src/app/rechercher/page.tsx index ad0d0c0..695b6f3 100644 --- a/src/app/rechercher/page.tsx +++ b/src/app/rechercher/page.tsx @@ -29,7 +29,10 @@ async function getSpecialites(specialitesId: string[], substancesId: string[]) { ) .where("Specialite.SpecId", "in", liste_CIS_MVP) .selectAll("Specialite") - .select("NomId") + .select(({ fn }) => [ + fn>("json_arrayagg", ["NomId"]).as("SubsNomId"), + ]) + .groupBy("Specialite.SpecId") .execute() : []; } @@ -105,7 +108,8 @@ async function getResults(query: string): Promise { specialiteGroups .filter(([, specialites]) => specialites.find( - (s) => s.NomId && s.NomId.trim() === substance.NomId.trim(), + (s) => + s.SubsNomId && s.SubsNomId.includes(substance.NomId.trim()), ), ) .forEach(([groupName, specialites]) => { @@ -133,7 +137,8 @@ async function getResults(query: string): Promise { if ( specialiteGroup && !acc.find( - (a) => "groupName" in a && a.groupName === specialiteGroup[0], + ({ item }) => + "groupName" in item && item.groupName === specialiteGroup[0], ) ) { const [groupName, specialites] = specialiteGroup;