Log NWS alerts to history regardless of push subscribers
Publish Container / publish (push) Successful in 2m55s

The alert history log was only populated inside the subscriber loop,
so it stayed empty when no push subscriptions existed. Now the cron
always checks and logs active NWS alerts for the dashboard location
before the subscriber early-return.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Nate EmmertandClaude Sonnet 4.6 committed 2026-09-02 08:37:14 -04:00
1 parent 5f7e490a6e
commit de9cb41d8b
1 file changed
+16
+16
View File
@@ -734,6 +734,22 @@ async function alertWatcherCron() {
} catch {} } catch {}
} }
// ── Log NWS alerts for the dashboard location regardless of subscribers ───────
const dashLat = dashAuth?.stationLat;
const dashLon = dashAuth?.stationLon;
if (dashLat != null) {
const dashAlertData = await fetch(`${base}/api/alerts?lat=${dashLat}&lon=${dashLon}`)
.then(r => r.json()).catch(() => ({ features: [] }));
for (const a of dashAlertData.features || []) {
const alertId = a.id || a.properties?.id;
if (alertId && !loggedAlertIds.has(alertId)) {
loggedAlertIds.add(alertId);
const p = a.properties || {};
recordAlertLog({ type: 'nws', alertId, event: p.event, headline: p.headline, effective: p.effective, expires: p.expires, lat: dashLat, lon: dashLon });
}
}
}
if (!pushSubscriptions.length) return; if (!pushSubscriptions.length) return;
for (const sub of [...pushSubscriptions]) { for (const sub of [...pushSubscriptions]) {