From 985230492f0c2543952bbac01378c033cced7d55 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 19 Oct 2024 21:39:57 -0700 Subject: de-dupe locations --- lib/locations.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/locations.ts b/lib/locations.ts index 560d5259..11981c19 100644 --- a/lib/locations.ts +++ b/lib/locations.ts @@ -1,7 +1,7 @@ import { err } from "$lib/logging"; import got from "got"; import { g, s } from "$lib/db"; -import { fields, pick } from "$lib/utils"; +import { fields, pick, uniq } from "$lib/utils"; export let getLocations = async () => { try { @@ -40,7 +40,10 @@ export let getLocations = async () => { locations.push(...previous); - await s("locations", locations); + await s( + "locations", + uniq(locations, (l) => l.id), + ); await s("locations:since", new Date().toISOString().split(".")[0] + "Z"); } catch (e) { err("problem fetching locations", e); -- cgit v1.2.3