-
Notifications
You must be signed in to change notification settings - Fork 77
feat: estimate iRating changes in practice #689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ export interface SessionVisibilitySettings { | |
|
|
||
| export interface StandingsWidgetSettings extends BaseWidgetSettings { | ||
| config: { | ||
| iratingChange: { enabled: boolean }; | ||
| iratingChange: { enabled: boolean; estimateInPractice?: boolean }; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This adds a persisted field to the Standings settings shape, but AGENTS.md reference: AGENTS.md:L12-L14 Useful? React with 👍 / 👎. |
||
| positionChange: { enabled: boolean }; | ||
| badge: { | ||
| enabled: boolean; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,17 @@ const EMPTY_NUMBERS: number[] = []; | |
| const EMPTY_BOOLEANS: boolean[] = []; | ||
| const EMPTY_TRACK_LOCATIONS: TrackLocation[] = []; | ||
|
|
||
| export const shouldCalculateIRatingChange = ( | ||
| eventType: string | undefined, | ||
| isOfficial: boolean, | ||
| sessionType: string | undefined, | ||
| estimateInPractice: boolean | ||
| ) => | ||
| (eventType === 'Race' && isOfficial) || | ||
| (eventType === 'Practice' && | ||
| sessionType === 'Practice' && | ||
| estimateInPractice); | ||
|
Comment on lines
+36
to
+45
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Exclude qualifying sessions during official race weekends. Line 42 returns
📍 Affects 2 files
🤖 Prompt for AI Agents |
||
|
|
||
| export const useDriverStandings = ( | ||
| settings?: StandingsWidgetSettings['config'] | ||
| ) => { | ||
|
|
@@ -173,11 +184,16 @@ export const useDriverStandings = ( | |
| ? augmentStandingsWithPositionChange(groupedByClass, qualifyingResults) | ||
| : groupedByClass; | ||
|
|
||
| // Calculate iRating changes for official race weekends | ||
| const iratingAugmentedGroupedByClass = | ||
| eventType === 'Race' && isOfficial | ||
| ? augmentStandingsWithIRating(positionChangeAugmentedGroupedByClass) | ||
| : positionChangeAugmentedGroupedByClass; | ||
| // Official race weekends retain the existing behavior. Practice estimates | ||
| // are opt-in because they are hypothetical and do not affect iRating. | ||
| const iratingAugmentedGroupedByClass = shouldCalculateIRatingChange( | ||
| eventType, | ||
| isOfficial, | ||
| sessionType, | ||
| settings?.iratingChange?.estimateInPractice ?? false | ||
|
Comment on lines
+189
to
+193
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When practice estimation is enabled, telemetry-driven standings recomputations now invoke AGENTS.md reference: AGENTS.md:L12-L14 Useful? React with 👍 / 👎. |
||
| ) | ||
| ? augmentStandingsWithIRating(positionChangeAugmentedGroupedByClass) | ||
| : positionChangeAugmentedGroupedByClass; | ||
|
|
||
| // Calculate gap to class leader when enabled OR when interval is enabled (interval needs gap data) | ||
| const gapAugmentedGroupedByClass = | ||
|
|
@@ -226,6 +242,7 @@ export const useDriverStandings = ( | |
| useLivePositionStandings, | ||
| isOfficial, | ||
| eventType, | ||
| settings?.iratingChange?.estimateInPractice, | ||
| gapEnabled, | ||
| intervalEnabled, | ||
| carIdxLap, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Give the switch an accessible name.
ToggleSwitchrenders an unnamedrole="switch"button. The siblingspandoes not label that button. Associate the text with the control througharia-labelledby, or extendToggleSwitchwith an accessible-label prop and passEstimate During Practice.🤖 Prompt for AI Agents