perf: group standings entries by round once instead of filtering per round#7651
perf: group standings entries by round once instead of filtering per round#7651Rathoz wants to merge 3 commits into
Conversation
ElectricalBoy
left a comment
There was a problem hiding this comment.
Lua-Modules/lua/wikis/commons/Standings.lua
Lines 212 to 221 in d9dd250
adjusting LPDB query condition to have the returned data to already be sorted would be more optimal, right? like adjusting order to roundindex asc, slotindex asc
then because all data is guaranteed to be sorted we could switch over to Array.groupAdjacentBy
| local entriesByRound = {} | ||
| Array.forEach(standingsEntries, function(entry) | ||
| local roundIndex = tonumber(entry.roundindex) | ||
| if roundIndex then | ||
| entriesByRound[roundIndex] = entriesByRound[roundIndex] or {} | ||
| table.insert(entriesByRound[roundIndex], entry) | ||
| end | ||
| end) |
There was a problem hiding this comment.
Done in dede56f — switched both manual grouping loops (here and the matching one in Parser.lua) to Array.groupBy.
d9dd250 to
e31259a
Compare
|
Applied the query-order change (
|
…round Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
dede56f to
808b763
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors standings parsing and model round-building to avoid repeatedly filtering the full entries list per round, replacing those repeated Array.filter passes with a single Array.groupBy pre-grouping keyed by round index to reduce overall work.
Changes:
- In
StandingsParser.parse, pre-groups computedentriesbyroundindexonce and reuses the grouped lists for tiebreaker calculation, placement resolution, and final-round definitive status assignment. - In
Standings.makeRounds, pre-groups LPDBstandingsentryrecords bytonumber(roundindex)once and maps/sorts per-round entries from that grouped structure (instead of filtering per round). - Adjusts LPDB query ordering to
roundindex asc, slotindex ascfor more deterministic record ordering during fetch.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lua/wikis/commons/Standings/Parser.lua | Replaces per-round filtering with a single grouping pass reused across the round-based computation loops. |
| lua/wikis/commons/Standings.lua | Replaces per-round filtering during round construction with a single grouping pass; refines LPDB ordering for fetched entries. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: ElectricalBoy <15651807+ElectricalBoy@users.noreply.github.com>
Summary
StandingsParser.parsepreviously filtered the full entry list per round three separate times (tiebreakers, placements, final-round definite statuses); replaced with a singleentriesByRoundgrouping pass before those loops.Standings.makeRoundspreviously ranArray.filterover all entries once per round at display time; replaced with one grouping pass keyed bytonumber(entry.roundindex)(thetonumberis preserved since records read from LPDB/wiki vars can have stringroundindex).Based on standings-tests-ai (PR #7647).
How did you test this change?
busted --run=ci: 605 successes / 0 failures / 0 errors —spec/standings_parser_spec.luaandspec/standings_model_spec.lualock placements, ordering, and round structure.luacheckon both changed files: 0 warnings / 0 errors.🤖 Generated with Claude Code