diff options
| author | Adam Soltys <[email protected]> | 2026-02-27 10:09:25 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-02-27 10:09:25 -0800 |
| commit | fd8f286e22f4f8b6a24123937c24c52b9c1407ba (patch) | |
| tree | 13aaf05b65dc510e05f7e5e53ce2de1de67d2d15 /lib | |
| parent | f3c7e821f12f55044689204ff2c4571be791bb9f (diff) | |
| download | coinos-server-fd8f286e22f4f8b6a24123937c24c52b9c1407ba.tar.gz coinos-server-fd8f286e22f4f8b6a24123937c24c52b9c1407ba.zip | |
map updates
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/locations.ts | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/locations.ts b/lib/locations.ts index 91bc4599..734cd027 100644 --- a/lib/locations.ts +++ b/lib/locations.ts @@ -1,4 +1,4 @@ -import { g, s } from "$lib/db"; +import { db, g, s } from "$lib/db"; import { err } from "$lib/logging"; import { fields, getUser } from "$lib/utils"; import got from "got"; @@ -49,8 +49,17 @@ export const getLocations = async () => { locations.push(...previous); - await s("locations", dedup(locations)); + const dedupedLocations = dedup(locations); + await s("locations", dedupedLocations); await s("locations:since", `${new Date().toISOString().split(".")[0]}Z`); + + for (const loc of dedupedLocations) { + if (loc.deleted_at) continue; + const { lat, lon } = loc.osm_json; + if (!(lat && lon)) continue; + await db.geoAdd("locations:geo", { longitude: lon, latitude: lat, member: String(loc.id) }); + await s(`location:${loc.id}`, loc); + } } catch (e) { console.log(e); err("problem fetching locations", e); |
