From fe62cadd6fb4a7e49f7d59401fc74ae0411e32a7 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 26 Aug 2024 21:17:43 -0700 Subject: typescript --- lib/locations.js | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 lib/locations.js (limited to 'lib/locations.js') diff --git a/lib/locations.js b/lib/locations.js deleted file mode 100644 index 39212d05..00000000 --- a/lib/locations.js +++ /dev/null @@ -1,40 +0,0 @@ -import fs from "fs"; -import { err } from "$lib/logging"; -import got from "got"; -import { g, s } from "$lib/db"; -import { fields, pick } from "$lib/utils"; - -export let getLocations = async () => { - try { - let locations = await got( - "https://api.btcmap.org/v2/elements?updated_since=2022-09-19T00:00:00Z", - ).json(); - - locations = locations.filter( - (l) => - l["osm_json"].tags && l["osm_json"].tags["payment:coinos"] === "yes", - ); - - locations.map((l) => { - let { bounds, lat, lon } = l["osm_json"]; - - l["osm_json"].lat = lat || (bounds.minlat + bounds.maxlat) / 2; - l["osm_json"].lon = lon || (bounds.minlon + bounds.maxlon) / 2; - }); - - for await (let l of locations) { - let username = l.tags["payment:coinos"]; - if (username) { - let uid = await g(`user:${username}`); - let user = await g(`user:${uid}`); - if (user) l["osm_json"].tags.user = pick(user, fields); - } - } - - await s("locations", locations); - } catch (e) { - err("problem fetching locations", e); - } - - setTimeout(getLocations, 60000); -}; -- cgit v1.2.3