mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-08-04 20:55:19 +02:00
chore: Remove duplicate adventures in search results
This commit is contained in:
parent
50a2cbcd4c
commit
ca04bc0095
1 changed files with 13 additions and 5 deletions
|
@ -26,12 +26,20 @@ export const GET: RequestHandler = async ({
|
||||||
const locationResults = await locationSearch(value, locals);
|
const locationResults = await locationSearch(value, locals);
|
||||||
const namesResults = await nameSearch(value, locals);
|
const namesResults = await nameSearch(value, locals);
|
||||||
|
|
||||||
|
// remove duplicates by id
|
||||||
|
let adventures: any = {};
|
||||||
|
activityResults.adventures.forEach((a: any) => {
|
||||||
|
adventures[a.id] = a;
|
||||||
|
});
|
||||||
|
locationResults.adventures.forEach((a: any) => {
|
||||||
|
adventures[a.id] = a;
|
||||||
|
});
|
||||||
|
namesResults.adventures.forEach((a: any) => {
|
||||||
|
adventures[a.id] = a;
|
||||||
|
});
|
||||||
|
|
||||||
return json({
|
return json({
|
||||||
adventures: [
|
adventures: Object.values(adventures),
|
||||||
...activityResults.adventures,
|
|
||||||
...locationResults.adventures,
|
|
||||||
...namesResults.adventures,
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
} else if (type === "activity") {
|
} else if (type === "activity") {
|
||||||
return json(await activitySearch(value, locals, isVisited));
|
return json(await activitySearch(value, locals, isVisited));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue