feat: added match-based X-axis toggle for VR History Graph#253
feat: added match-based X-axis toggle for VR History Graph#253patchzyy merged 1 commit intoTeamWheelWizard:devfrom
Conversation
📝 WalkthroughWalkthroughThe VrHistoryGraph component gains a new UI toggle ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@WheelWizard/Views/Patterns/VrHistoryGraph.axaml.cs`:
- Around line 431-463: Add regression tests for VrHistoryGraph's X-axis
branching (UseMatchesAsXAxis true/false) exercising 1-point, 2-point, and
multi-point orderedByDate scenarios: create test fixtures that set orderedByDate
with 1, 2, and >2 entries, toggle UseMatchesAsXAxis, call the code path that
computes GraphStartLabel/GraphMidLabel/GraphEndLabel and the point projection
logic (the lambda producing Point(x,y)), and assert expected label strings and x
coordinates (for matches: 0, mid = i/(n-1)*GraphWidth etc.; for time axis:
computed from graphStart/graphEnd and totalSeconds). Cover boundary
vrRange/minVr cases to ensure y calculation (GraphHeight - (entry.TotalVr -
minVr)/vrRange*GraphHeight) handles zero/one ranges without division-by-zero or
NaN by asserting y values and behavior.
- Around line 59-73: The toggle setter for UseMatchesAsXAxis currently
re-applies cached _lastHistoryResponse even when a reload is in progress; update
the setter to skip calling ApplyHistoryData(_lastHistoryResponse,
_selectedHistoryDays) when IsLoading is true (or when a backing flag like
_isLoading indicates an active load), or clear/ignore _lastHistoryResponse
during loads so stale data isn't rendered; specifically modify the
UseMatchesAsXAxis setter to check IsLoading (or _isLoading) before invoking
ApplyHistoryData and only apply cached data when not loading.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 2014e141-5eb9-440d-9d3c-28d74cbae710
📒 Files selected for processing (2)
WheelWizard/Views/Patterns/VrHistoryGraph.axamlWheelWizard/Views/Patterns/VrHistoryGraph.axaml.cs
| public bool UseMatchesAsXAxis | ||
| { | ||
| get => _useMatchesAsXAxis; | ||
| set | ||
| { | ||
| if (_useMatchesAsXAxis == value) | ||
| return; | ||
|
|
||
| _useMatchesAsXAxis = value; | ||
| OnPropertyChanged(nameof(UseMatchesAsXAxis)); | ||
|
|
||
| if (_lastHistoryResponse != null) | ||
| ApplyHistoryData(_lastHistoryResponse, _selectedHistoryDays); | ||
| } | ||
| } |
There was a problem hiding this comment.
Prevent stale cached data from being re-applied during active reloads.
At Line 70-Line 72, toggling can re-render _lastHistoryResponse while IsLoading is true, which can temporarily show stale data from a previous context with the newly selected range.
Suggested fix
public bool UseMatchesAsXAxis
{
get => _useMatchesAsXAxis;
set
{
if (_useMatchesAsXAxis == value)
return;
_useMatchesAsXAxis = value;
OnPropertyChanged(nameof(UseMatchesAsXAxis));
- if (_lastHistoryResponse != null)
+ if (!IsLoading && _lastHistoryResponse != null)
ApplyHistoryData(_lastHistoryResponse, _selectedHistoryDays);
}
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| public bool UseMatchesAsXAxis | |
| { | |
| get => _useMatchesAsXAxis; | |
| set | |
| { | |
| if (_useMatchesAsXAxis == value) | |
| return; | |
| _useMatchesAsXAxis = value; | |
| OnPropertyChanged(nameof(UseMatchesAsXAxis)); | |
| if (_lastHistoryResponse != null) | |
| ApplyHistoryData(_lastHistoryResponse, _selectedHistoryDays); | |
| } | |
| } | |
| public bool UseMatchesAsXAxis | |
| { | |
| get => _useMatchesAsXAxis; | |
| set | |
| { | |
| if (_useMatchesAsXAxis == value) | |
| return; | |
| _useMatchesAsXAxis = value; | |
| OnPropertyChanged(nameof(UseMatchesAsXAxis)); | |
| if (!IsLoading && _lastHistoryResponse != null) | |
| ApplyHistoryData(_lastHistoryResponse, _selectedHistoryDays); | |
| } | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@WheelWizard/Views/Patterns/VrHistoryGraph.axaml.cs` around lines 59 - 73, The
toggle setter for UseMatchesAsXAxis currently re-applies cached
_lastHistoryResponse even when a reload is in progress; update the setter to
skip calling ApplyHistoryData(_lastHistoryResponse, _selectedHistoryDays) when
IsLoading is true (or when a backing flag like _isLoading indicates an active
load), or clear/ignore _lastHistoryResponse during loads so stale data isn't
rendered; specifically modify the UseMatchesAsXAxis setter to check IsLoading
(or _isLoading) before invoking ApplyHistoryData and only apply cached data when
not loading.
Purpose of this PR
The VR History graph previously only used time for the X-axis.
This adds a toggle to switch the X-axis to “Matches,” making it easier to see how VR changes per game.
How to Test
What Changed
VrHistoryGraph.axamlheaderApplyHistoryDatato support both time-based and match-based X-axisRelated Issue
N/A (feature request)
Checklist before merging
Summary by CodeRabbit
New Features
Style