mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2026-03-25 01:33:20 -04:00
chore: Remove duplicate adventures in search results
This commit is contained in:
@@ -26,12 +26,20 @@ export const GET: RequestHandler = async ({
|
||||
const locationResults = await locationSearch(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({
|
||||
adventures: [
|
||||
...activityResults.adventures,
|
||||
...locationResults.adventures,
|
||||
...namesResults.adventures,
|
||||
],
|
||||
adventures: Object.values(adventures),
|
||||
});
|
||||
} else if (type === "activity") {
|
||||
return json(await activitySearch(value, locals, isVisited));
|
||||
|
||||
Reference in New Issue
Block a user