const range = history_view.range;
filtered_data = (history_view.data || []).filter(elem => !range || (elem.date >= range.from && elem.date <= range.to));
nothing_selected_elem.textContent = history_view.error ? `Cannot load the history: ${history_view.error}`
- : !history_view.data ? 'Loading…' : history_view.data.length ? 'No results for this metric' : 'No results';
+ : !history_view.data ? 'Loading…' : !history_view.data.length ? 'No results'
+ : filtered_data.length ? 'No results for this metric' : 'No results in this date range';
} else {
applyTopRowFilters();
@@ -2576,7 +2598,13 @@
Detailed Comparison
history.pushState(historyState(), '',
window.location.pathname + (window.location.search || '') + '#' + encodeState(selectors)
+ (history_view ? '&history=' + encodeURIComponent(history_view.key) : '')
- + (history_view?.range ? `&from=${history_view.range.from}&to=${history_view.range.to}` : ''));
+ + (history_view?.range?.last ? `&last=${history_view.range.last}`
+ : history_view?.range ? `&from=${history_view.range.from}&to=${history_view.range.to}` : ''));
+}
+
+/// The range of the last `days` days, relative to today, kept as `&last=` in the URL so that the link stays fresh.
+function lastDaysRange(days) {
+ return {from: new Date(Date.now() - days * 86400000).toISOString().slice(0, 10), to: max_date, last: days};
}
/// The selectors and the history view from the URL.
@@ -2586,7 +2614,9 @@