fix(dashboard): use start bound for hourly chart date filter#113
Open
sivlek14 wants to merge 2 commits into
Open
fix(dashboard): use start bound for hourly chart date filter#113sivlek14 wants to merge 2 commits into
sivlek14 wants to merge 2 commits into
Conversation
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 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes a dashboard JavaScript runtime error in applyFilter() where the hourly chart filter referenced an undefined cutoff variable, and adds a Python regression test to prevent reintroducing the issue.
Changes:
- Update the hourly chart data filter to use the
startbound returned bygetRangeBounds(selectedRange)instead of an undefined variable. - Add regression tests that inspect
HTML_TEMPLATEto ensure the hourly filter usesstartand does not referencecutoff.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
dashboard.py |
Fixes the hourly chart’s date-range filtering logic in the embedded JS template. |
tests/test_dashboard.py |
Adds static regression tests to catch undefined-variable usage in the hourly filtering code. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+272
to
+277
| 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] |
Comment on lines
+275
to
+278
| 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) |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| date range caused a ReferenceError, silently emptying the hourly chart.""" | ||
|
|
||
| def test_no_undefined_cutoff_in_template(self): | ||
| self.assertNotIn("cutoff", HTML_TEMPLATE) |
Comment on lines
+275
to
+280
| 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) | ||
|
|
||
|
|
Comment on lines
744
to
748
| 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) | ||
| ); |
Author
|
@copilot apply changes based on the comments in this thread |
Author
|
@copilot apply changes based on the comments in this thread |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
applyFilter()destructures{ start, end }fromgetRangeBounds(selectedRange)and uses them consistently for the daily chart and session filters — but the hourly chart filter referenced an undefinedcutoffvariable:Under any active date range (anything other than "all"), this threw a
ReferenceError, causing the "Average Hourly Distribution" chart to silently empty.A static regression test is added to
tests/test_dashboard.pythat assertscutoffis absent fromHTML_TEMPLATEand that the hourly filter uses thestartbound.Test plan
python3 -m unittest tests.test_dashboard.TestApplyFilterHourlyRegression -v— two new tests passpython3 -m unittest discover -s tests -v— full suite green (96 tests)🤖 Generated with Claude Code