mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
fix(firms): drop LIVE from the row's source and the voice answer for a snapshot that ends at a set time
The catalog source 'NASA FIRMS · LIVE' still led the row; getStats() now names the source 'NASA FIRMS' for such a snapshot. get_active_fires says "in the 24 hours to" its end and reports window_end. The end is checked to be a printable time, cleared under KEY REQUIRED, the test moves next to the layer, and the changelog and CURRENT-STATE describe it.
This commit is contained in:
1 parent
43706b8dd0
commit
4ef0869a87
10 files changed
+163
-61
No files matched your search
@@ -3,6 +3,10 @@ import { fireDetectionKey } from '../../data/firmsLabels.js';
|
||||
import { filterFires } from '../../data/firmsIntensity.js';
|
||||
import { msg } from '../../i18n/index.js';
|
||||
|
||||
/** A time a Date can print: epoch ms within JavaScript's date range. */
|
||||
const isSnapshotEnd = (value) =>
|
||||
Number.isFinite(value) && Math.abs(value) <= 8_640_000_000_000_000;
|
||||
|
||||
export function createIngestion({
|
||||
layerState,
|
||||
services,
|
||||
@@ -32,6 +36,7 @@ export function createIngestion({
|
||||
return;
|
||||
if (payload.keyRequired) {
|
||||
layerState._keyRequired = true;
|
||||
layerState._at = null;
|
||||
layerState._error = null;
|
||||
layerState._stale = false;
|
||||
return;
|
||||
@@ -41,7 +46,7 @@ export function createIngestion({
|
||||
layerState._stale = Boolean(payload?.stale);
|
||||
// A snapshot of the 24 hours to a set time names it; one of the
|
||||
// trailing 24 hours to now does not.
|
||||
layerState._at = Number.isFinite(payload?.at) ? payload.at : null;
|
||||
layerState._at = isSnapshotEnd(payload?.at) ? payload.at : null;
|
||||
const previousSelection = layerState._selectedFire;
|
||||
layerState._selectedFire = null;
|
||||
layerState._allFires = adaptFirmsRecords(payload?.fires);
|
||||
|
||||
@@ -233,8 +233,10 @@ export function createQueries({
|
||||
loading: layerState._loading,
|
||||
stale: layerState._stale,
|
||||
// The end of the 24 hours shown when the snapshot ends at a set time;
|
||||
// null for the trailing 24 hours to now.
|
||||
// null for the trailing 24 hours to now. Such a snapshot is not live,
|
||||
// so the row names the provider without the catalog's "LIVE".
|
||||
at: Number.isFinite(layerState._at) ? layerState._at : null,
|
||||
...(Number.isFinite(layerState._at) ? { source: 'NASA FIRMS' } : {}),
|
||||
// The machine-readable half of the keyless state, ahead of the human
|
||||
// strings below: without it "no key configured" is indistinguishable
|
||||
// from a broken feed, and the row reads as a fault instead of a step
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { getLocale, setLocale } from '../../i18n/index.js';
|
||||
import { createModel } from './model.js';
|
||||
import { createQueries } from './queries.js';
|
||||
|
||||
test('a FIRMS snapshot that ends at a set time names it instead of LIVE', (context) => {
|
||||
const now = 1800000000000;
|
||||
context.mock.method(Date, 'now', () => now);
|
||||
const previousLocale = getLocale();
|
||||
const at = Date.UTC(2026, 9, 21, 15);
|
||||
const layerState = {
|
||||
_loading: false,
|
||||
_stale: false,
|
||||
_keyRequired: false,
|
||||
_error: null,
|
||||
_lastUpdate: now - 120000,
|
||||
_at: at,
|
||||
_count: 1,
|
||||
_cellCount: 0,
|
||||
_fires: [],
|
||||
};
|
||||
const model = createModel({ services: { anchors: {} } });
|
||||
const { methods } = createQueries({
|
||||
layerState,
|
||||
components: { model },
|
||||
config: {},
|
||||
});
|
||||
try {
|
||||
setLocale('en');
|
||||
assert.equal(methods.getStats().loadingLabel, '24 h to 10-21 15:00 UTC');
|
||||
assert.equal(methods.getStats().at, at);
|
||||
assert.equal(methods.getStats().source, 'NASA FIRMS', 'the row drops LIVE');
|
||||
setLocale('de');
|
||||
assert.equal(
|
||||
methods.getStats().loadingLabel,
|
||||
'24 Std. bis 21.10. 15:00 UTC',
|
||||
);
|
||||
layerState._at = null;
|
||||
setLocale('en');
|
||||
assert.equal(methods.getStats().loadingLabel, 'LIVE · updated 2m ago');
|
||||
assert.equal(methods.getStats().at, null);
|
||||
assert.equal(methods.getStats().source, undefined);
|
||||
} finally {
|
||||
setLocale(previousLocale);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user