aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-10-15 14:12:50 -0700
committerAdam Soltys <[email protected]>2024-10-15 14:12:50 -0700
commit4501538630af9d6026fe5661da0386d1b5d65008 (patch)
tree408f64e7fabe8eb98802c221ef86deb07f1eaf0c
parentaa165827fdeba6bb4c0602f0a0168570d6379dd9 (diff)
downloadcoinos-server-4501538630af9d6026fe5661da0386d1b5d65008.tar.gz
coinos-server-4501538630af9d6026fe5661da0386d1b5d65008.zip
limit location fetching to once a minute
-rw-r--r--lib/locations.ts3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/locations.ts b/lib/locations.ts
index 122a6c3a..4122c25a 100644
--- a/lib/locations.ts
+++ b/lib/locations.ts
@@ -5,8 +5,10 @@ import { fields, pick } from "$lib/utils";
export let getLocations = async () => {
try {
+ let previous = await g("locations");
let since = await g("locations:since");
if (!since) since = "2022-09-19T00:00:00Z";
+ if (Date.now() - new Date(since).getTime() < 60000) return;
let locations: Array<any> = await got(
`https://api.btcmap.org/v2/elements?updated_since=${since}`,
@@ -36,7 +38,6 @@ export let getLocations = async () => {
}
}
- let previous = await g("locations");
locations.push(...previous);
await s("locations", locations);