fix: All-time range fills the date pickers with the DB's first record date
CI/CD Pipeline - Northern Thailand Ping River Monitor / Test Suite (3.11) (push) Failing after 1m4s
CI/CD Pipeline - Northern Thailand Ping River Monitor / Build Docker Image (push) Skipped
CI/CD Pipeline - Northern Thailand Ping River Monitor / Integration Test with Services (push) Skipped
CI/CD Pipeline - Northern Thailand Ping River Monitor / Deploy to Staging (push) Skipped
CI/CD Pipeline - Northern Thailand Ping River Monitor / Deploy to Production (push) Skipped
CI/CD Pipeline - Northern Thailand Ping River Monitor / Performance Test (push) Skipped
CI/CD Pipeline - Northern Thailand Ping River Monitor / Code Quality (push) Successful in 30s
CI/CD Pipeline - Northern Thailand Ping River Monitor / Cleanup (push) Successful in 3s
CI/CD Pipeline - Northern Thailand Ping River Monitor / Test Suite (3.11) (push) Failing after 1m4s
CI/CD Pipeline - Northern Thailand Ping River Monitor / Build Docker Image (push) Skipped
CI/CD Pipeline - Northern Thailand Ping River Monitor / Integration Test with Services (push) Skipped
CI/CD Pipeline - Northern Thailand Ping River Monitor / Deploy to Staging (push) Skipped
CI/CD Pipeline - Northern Thailand Ping River Monitor / Deploy to Production (push) Skipped
CI/CD Pipeline - Northern Thailand Ping River Monitor / Performance Test (push) Skipped
CI/CD Pipeline - Northern Thailand Ping River Monitor / Code Quality (push) Successful in 30s
CI/CD Pipeline - Northern Thailand Ping River Monitor / Cleanup (push) Successful in 3s
Uses first_timestamp from /api/stats (2018-08-01 fallback) as the start date and today as the end, instead of clearing the pickers.
This commit is contained in:
@@ -1278,6 +1278,7 @@
|
|||||||
if (!response.ok) { strip.style.display = 'none'; return; }
|
if (!response.ok) { strip.style.display = 'none'; return; }
|
||||||
const stats = await response.json();
|
const stats = await response.json();
|
||||||
const fmtDate = (value) => new Date(value).toLocaleDateString([], { day: 'numeric', month: 'short', year: 'numeric' });
|
const fmtDate = (value) => new Date(value).toLocaleDateString([], { day: 'numeric', month: 'short', year: 'numeric' });
|
||||||
|
state.dbFirstDate = String(stats.first_timestamp).slice(0, 10); // feeds the All-time date range
|
||||||
$('db-total').textContent = Number(stats.total_measurements).toLocaleString();
|
$('db-total').textContent = Number(stats.total_measurements).toLocaleString();
|
||||||
if (stats.rid_measurements != null) {
|
if (stats.rid_measurements != null) {
|
||||||
const fmtNum = (value) => Number(value || 0).toLocaleString();
|
const fmtNum = (value) => Number(value || 0).toLocaleString();
|
||||||
@@ -1320,15 +1321,13 @@
|
|||||||
if ($('history-range').value === 'custom') return;
|
if ($('history-range').value === 'custom') return;
|
||||||
state.useDates = false;
|
state.useDates = false;
|
||||||
const hours = Number($('history-range').value);
|
const hours = Number($('history-range').value);
|
||||||
if (hours >= 876000) {
|
|
||||||
$('history-start').value = ''; $('history-end').value = '';
|
|
||||||
} else {
|
|
||||||
// Mirror the chosen range into the date pickers (local dates)
|
// Mirror the chosen range into the date pickers (local dates)
|
||||||
const isoLocal = (d) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
const isoLocal = (d) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
$('history-end').value = isoLocal(now);
|
$('history-end').value = isoLocal(now);
|
||||||
$('history-start').value = isoLocal(new Date(now.getTime() - hours * 3600 * 1000));
|
$('history-start').value = hours >= 876000
|
||||||
}
|
? (state.dbFirstDate || '2018-08-01') // All time: DB's first record
|
||||||
|
: isoLocal(new Date(now.getTime() - hours * 3600 * 1000));
|
||||||
if (state.selectedStation) loadHistory(state.selectedStation);
|
if (state.selectedStation) loadHistory(state.selectedStation);
|
||||||
else $('history-status').textContent = 'Select a station first — click one on the map or in the list';
|
else $('history-status').textContent = 'Select a station first — click one on the map or in the list';
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user