Skip to content

perf: index standings import opponents by name instead of linear search#7653

Open
Rathoz wants to merge 1 commit into
standings-tests-aifrom
standings-import-keyed-opponents
Open

perf: index standings import opponents by name instead of linear search#7653
Rathoz wants to merge 1 commit into
standings-tests-aifrom
standings-import-keyed-opponents

Conversation

@Rathoz

@Rathoz Rathoz commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Per-match-opponent linear Opponent.same scan replaced by an Opponent.toName-keyed map, reducing complexity from O(matches × opponents) to O(matches).
  • Team opponents get a one-time Opponent.same fallback scan to handle renamed teams (which differ by name but compare equal via historicaltemplate); on a hit the new key is aliased into the map so the cost is paid at most once per renamed team.
  • TBD opponents continue to collapse onto a single entry (same behavior as before — they resolve to the same Opponent.toName key and are filtered out by Opponent.isTbd at the end).

How did you test this change?

  • busted --run=ci: 605 successes / 0 failures / 0 errors — includes spec/standings_import_spec.lua (7 cases covering dedupe across rounds, TBD dropping, score mappers).
  • luacheck lua/wikis/commons/Standings/Parse/Lpdb.lua: 0 warnings / 0 errors.
  • Based on standings-tests-ai (PR test: add integration tests for standings #7647), whose import spec covers the relevant behavior.

🤖 Generated with Claude Code

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Rathoz Rathoz requested review from a team as code owners June 12, 2026 15:55
local key = Opponent.toName(opponent)
local standingsOpponentData = opponentsByName[key]
if not standingsOpponentData and opponent.type == Opponent.team then
-- renamed teams have differing names but compare equal via historicaltemplate

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

"renamed teams have differing names" is an incorrect assumption if i am not mistaken:

  • Opponent.toName returns TeamTemplate.toPageName (with normalized underscores)
  • TeamTemplate.toPageName returns set pagename, resolves redirects, and normalizes underscores

A correctly setup HTT should have page redirects for each of the subtemplates to the same page.
Thus they'd end up with the same name via Opponent.toName.

This would only be different if we remove the forced resolving of redirects (which i'd personally advocate for due to A/B teams, but not sure if that is going to happen and the side effects of it)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

that is not necessarily true
there exist some team templates that have different page names set in their sub templates where no redirect exists between them
so if you would catch such a tt and process it at different dates (one before, one after the switch) you would get different pagenames returned

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What is the usecase of such a TT?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

no idea i hate them
iirc cs had some of them for some reasons

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ah, you refer to the mibr vs MIBR things.
IIRC they fixed these by now, as they had other things broken.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

yeah exactly
if those are solved, then you are right :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants