From 0b3ba39c956611d3e6ee24876fe278e1788ec0f9 Mon Sep 17 00:00:00 2001 From: Kelvis Artigas <9992885+sivlek14@users.noreply.github.com> Date: Fri, 8 May 2026 00:11:00 -0400 Subject: [PATCH 1/2] fix(dashboard): use start bound for hourly chart date filter applyFilter() destructures { start, end } from getRangeBounds() but the hourly filter referenced an undefined `cutoff` variable. Under any active date range this threw a ReferenceError, silently emptying the "Average Hourly Distribution" chart. Fixed by using `start`, consistent with the daily and sessions filters in the same function. Adds a static regression test that asserts `cutoff` is absent from HTML_TEMPLATE and that the hourly filter references the `start` bound. Co-Authored-By: Claude Sonnet 4.6 --- dashboard.py | 2 +- tests/test_dashboard.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/dashboard.py b/dashboard.py index ebf8d5f..44b5707 100644 --- a/dashboard.py +++ b/dashboard.py @@ -742,7 +742,7 @@ 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) ); 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() From 954539fdb34d76105f0b64cd62b949ac9772e890 Mon Sep 17 00:00:00 2001 From: Kelvis Artigas <9992885+sivlek14@users.noreply.github.com> Date: Fri, 8 May 2026 01:31:12 -0400 Subject: [PATCH 2/2] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- dashboard.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dashboard.py b/dashboard.py index 44b5707..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) && (!start || r.day >= start) + selectedModels.has(r.model) && + (!start || r.day >= start) && + (!end || r.day <= end) ); const hourlyAgg = aggregateHourly(hourlySrc, hourlyTZ);