diff --git a/dashboard.py b/dashboard.py index ebf8d5f..ff153ac 100644 --- a/dashboard.py +++ b/dashboard.py @@ -742,7 +742,9 @@ def get_dashboard_data(db_path=DB_PATH): // Hourly aggregation (filtered by model + range, then bucketed by UTC hour) const hourlySrc = (rawData.hourly_by_model || []).filter(r => - selectedModels.has(r.model) && (!cutoff || r.day >= cutoff) + selectedModels.has(r.model) && + (!start || r.day >= start) && + (!end || r.day <= end) ); const hourlyAgg = aggregateHourly(hourlySrc, hourlyTZ); diff --git a/tests/test_dashboard.py b/tests/test_dashboard.py index 76287d1..4da4b4e 100644 --- a/tests/test_dashboard.py +++ b/tests/test_dashboard.py @@ -264,5 +264,19 @@ def test_prices_match(self): ) +class TestApplyFilterHourlyRegression(unittest.TestCase): + """Regression: applyFilter() referenced `cutoff` (undefined) for the hourly + chart filter instead of the `start` bound from getRangeBounds(). Any active + date range caused a ReferenceError, silently emptying the hourly chart.""" + + def test_no_undefined_cutoff_in_template(self): + self.assertNotIn("cutoff", HTML_TEMPLATE) + + def test_hourly_filter_uses_start_bound(self): + idx = HTML_TEMPLATE.index("hourlySrc") + snippet = HTML_TEMPLATE[idx:idx + 300] + self.assertIn("!start || r.day >= start", snippet) + + if __name__ == "__main__": unittest.main()