Conversation
There was a problem hiding this comment.
Pull request overview
Updates the “Oldest standing records” statistics queries to compute current WR/CR/NR ages directly from the results table (instead of relying on ranks_single / ranks_average), restoring functionality after the ranks tables became empty.
Changes:
- Rewrites the World/Continental/National record queries using CTEs +
row_number()overresultsjoined withcompetitions. - Adds/updates a
sqlQueryCustomvariant intended to compute per-person (WCA ID) results for this statistic. - Adjusts selected competition fields used for link formatting (e.g., using
c.name).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| c.start_date, | ||
| event_id, | ||
| 'Average' record_type, | ||
| best record, |
There was a problem hiding this comment.
In sqlQueryCustom, the 'Average' branch selects best as the record value even though it ranks by average and is labeled as 'Average'. This will display the wrong value for average personal bests; select average as the record value in that branch.
| best record, | |
| average record, |
| c.start_date, | ||
| event_id, | ||
| 'Average' record_type, | ||
| best record, |
There was a problem hiding this comment.
In the 'Average' branch of the WR CTE, the query selects best as the record value even though it filters on regional_average_record = 'WR'. This will display the single result instead of the average for current average WRs; use the average column as the record value for this branch.
| best record, | |
| average record, |
| c.start_date, | ||
| event_id, | ||
| 'Average' record_type, | ||
| best record, |
There was a problem hiding this comment.
In the 'Average' branch of the continental records CTE, the query selects best as the record value while filtering on regional_average_record. This will format/display the single result under the 'Average' type; use average as the record value in this branch.
| best record, | |
| average record, |
| c.start_date, | ||
| event_id, | ||
| 'Average' record_type, | ||
| best record, |
There was a problem hiding this comment.
In the 'Average' branch of the national records CTE, the query selects best as the record value while filtering on regional_average_record = 'NR'. This will show the single result in the 'Average' row; use the average column as the record value for this branch.
| best record, | |
| average record, |
| r.person_name, | ||
| c.id competition_id, | ||
| c.name competition, | ||
| r.country_id region, | ||
| row_number() over ( |
There was a problem hiding this comment.
The national records query now outputs region as r.country_id (country code/id) instead of the country name (previously countries.name). If the UI expects a human-readable region label in this column, join countries and select the name here to avoid regressing the output format.
After thewca/worldcubeassociation.org#13304, tables that we were using to compute oldest standing records are now empty. This PR introduces a way to compute oldest standing records without using
ranks_singleandranks_average, only usingresults.