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 2 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.
…round Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
d9dd250 to
e31259a
Compare
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Applied the query-order change (
|
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