Skip to content

Fix oldest stading record#147

Open
campos20 wants to merge 2 commits intomainfrom
feature/fix-oldest-stading-record
Open

Fix oldest stading record#147
campos20 wants to merge 2 commits intomainfrom
feature/fix-oldest-stading-record

Conversation

@campos20
Copy link
Member

@campos20 campos20 commented Mar 1, 2026

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_single and ranks_average, only using results.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() over results joined with competitions.
  • Adds/updates a sqlQueryCustom variant 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,
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
best record,
average record,

Copilot uses AI. Check for mistakes.
c.start_date,
event_id,
'Average' record_type,
best record,
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
best record,
average record,

Copilot uses AI. Check for mistakes.
c.start_date,
event_id,
'Average' record_type,
best record,
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
best record,
average record,

Copilot uses AI. Check for mistakes.
c.start_date,
event_id,
'Average' record_type,
best record,
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
best record,
average record,

Copilot uses AI. Check for mistakes.
Comment on lines +197 to +201
r.person_name,
c.id competition_id,
c.name competition,
r.country_id region,
row_number() over (
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants