Skip to content

Commit ec6a2ee

Browse files
Merge pull request #44 from TheLinuxGuy-ssh/personal
Refresh button updates, to handle sync state, Increased rate limits f…
2 parents d904695 + d094a8f commit ec6a2ee

5 files changed

Lines changed: 7 additions & 27 deletions

File tree

docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
services:
22
duskmeter:
3-
# Use the published image from GitHub Container Registry (default).
4-
# Remove the `image` line and uncomment `build: .` to build locally instead.
5-
image: ghcr.io/thelinuxguy-ssh/duskmeter:latest
6-
# build: .
3+
# Build locally from source.
4+
# To use the published image instead, comment `build:` and uncomment `image:`.
5+
build: .
6+
# image: ghcr.io/thelinuxguy-ssh/duskmeter:latest
77
ports:
88
- "3000:3000"
99
environment:

src/lib/components/Header.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@
7777
<div class="flex items-center gap-2 ml-auto">
7878
<button
7979
onclick={onRefresh}
80-
class="flex items-center gap-1.5 h-7 px-2.5 text-[11px] font-medium text-text-dim hover:text-accent transition-colors duration-150"
80+
disabled={$refreshing}
81+
class="flex items-center gap-1.5 h-7 px-2.5 text-[11px] font-medium transition-colors duration-150 {$refreshing ? 'text-text-faint cursor-wait opacity-60' : 'text-text-dim hover:text-accent'}"
8182
aria-label="Refresh data"
82-
title="Refresh data from satellite and ground sources"
83+
title={$refreshing ? "Syncing data from satellite and ground sources" : "Refresh data from satellite and ground sources"}
8384
>
8485
<RefreshCw size={13} class={$refreshing ? "animate-spin" : ""} />
8586
<span class="hidden md:inline">{$refreshing ? "Syncing…" : "Refresh"}</span>

src/routes/(marketing)/+page.svelte

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<svelte:head>
22
<title>Duskmeter — Corrected Sky Brightness Estimates</title>
33
<meta name="description" content="Duskmeter fuses VIIRS satellite radiance with ground-truth sky brightness observations from Globe at Night to produce corrected light pollution estimates for observatories, dark-sky parks, and researchers." />
4-
<link rel="preconnect" href="https://fonts.googleapis.com" />
5-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="anonymous" />
6-
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500;600&family=Space+Grotesk:wght@500;600;700&display=swap" rel="stylesheet" />
74
</svelte:head>
85

96
<script lang="ts">

src/routes/api/assess-all/+server.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@ export async function GET() {
1717

1818
export async function POST({ url }) {
1919
try {
20-
const lastAssess = db.prepare("SELECT value FROM sync_state WHERE key = 'last_assess_at'").get() as { value: string } | undefined;
21-
if (lastAssess) {
22-
const elapsed = Date.now() - Date.parse(lastAssess.value);
23-
if (elapsed < 30 * 60 * 1000) {
24-
return json({ error: "Assessment ran recently. Wait 30 minutes between runs." }, { status: 429 });
25-
}
26-
}
27-
2820
const runLlm = url.searchParams.get("llm") === "true";
2921
const results = await assessAllSites(runLlm);
3022
db.prepare("INSERT OR REPLACE INTO sync_state (key, value) VALUES ('last_assess_at', ?)").run(new Date().toISOString());

src/routes/api/sites/[id]/assess/+server.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,11 @@ import { checkSite } from "$lib/server/alerts";
55

66
export async function POST({ params, url }) {
77
try {
8-
const lastKey = `assess_${params.id}_at`;
9-
const last = db.prepare("SELECT value FROM sync_state WHERE key = ?").get(lastKey) as { value: string } | undefined;
10-
if (last) {
11-
const elapsed = Date.now() - Date.parse(last.value);
12-
if (elapsed < 5 * 60 * 1000) {
13-
return json({ error: "Assessment ran recently. Wait 5 minutes between runs for this site." }, { status: 429 });
14-
}
15-
}
16-
178
const runLlm = url.searchParams.get("llm") === "true";
189
const result = await assessSite(params.id, runLlm);
1910
if (!result) {
2011
return json({ error: "Site not found" }, { status: 404 });
2112
}
22-
db.prepare("INSERT OR REPLACE INTO sync_state (key, value) VALUES (?, ?)").run(lastKey, new Date().toISOString());
2313
const alerts = checkSite(params.id);
2414
return json({ ...result, alertsCreated: alerts.created, alerts: alerts.alerts });
2515
} catch (e: any) {

0 commit comments

Comments
 (0)