Skip to content

perf: render standings directly from the model on the producing page#7655

Open
Rathoz wants to merge 2 commits into
mainfrom
standings-skip-var-roundtrip
Open

perf: render standings directly from the model on the producing page#7655
Rathoz wants to merge 2 commits into
mainfrom
standings-skip-var-roundtrip

Conversation

@Rathoz

@Rathoz Rathoz commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • StandingsStorage.run now returns {record, entries} where record is a model-ready shallow copy of the storage record with matches restored as a Lua table (not a JSON string), and pagename set to the current page title
  • StandingsTable.fromTemplate captures the return value and calls Standings.standingsFromRecord(stored.record, stored.entries) to build the model directly, then renders StandingsDisplay{standings = model} — eliminating the full stringify+parse round-trip through the wiki variable on the producing page
  • Widget/Standings accepts an alternative standings prop (a prebuilt StandingsModel); when present it skips Standings.getStandingsTable entirely; the existing pageName/standingsIndex path is untouched
  • The wiki-variable write (saveVars) is unchanged, so cross-template consumers (and later {{Standings}} transclusions on the same page) continue to work via the var path
  • A new spec case 'direct-path render matches var-path render' builds a standings table, renders it both via the returned model and via the page-variable read, and asserts the two HTML strings are identical

How did you test this change?

  • busted --run=ci: 606 successes / 0 failures / 0 errors (605 pre-existing + 1 new equality spec)
  • luacheck on all modified files: 0 warnings / 0 errors

🤖 Generated with Claude Code

@Rathoz Rathoz requested review from a team as code owners June 12, 2026 16:03

@hjpalpha hjpalpha left a comment

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.

seems reasonable on phone

@mbergen

mbergen commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

🤖 Generated with Claude Code

Does this only apply to the PR description or also the code itself?

@Rathoz

Rathoz commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator Author

Both, used it as a test scenario

Base automatically changed from standings-tests-ai to main July 2, 2026 09:51
Rathoz and others added 2 commits July 2, 2026 11:54
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 2, 2026 09:55
@Rathoz Rathoz force-pushed the standings-skip-var-roundtrip branch from d325db1 to 0f51ba5 Compare July 2, 2026 09:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes standings rendering on the producing page by building and rendering the StandingsModel directly from StandingsStorage.run() output, avoiding the stringify/parse round-trip through page variables while keeping the wiki-variable write path intact for cross-template consumers.

Changes:

  • StandingsStorage.run now returns { record, entries }, where record is tailored for direct model construction (notably matches as a Lua table and pagename populated).
  • StandingsTable.fromTemplate consumes that return value to build a model via Standings.standingsFromRecord(...) and renders via StandingsDisplay{standings = model}.
  • Widget/Standings accepts an optional prebuilt standings prop and skips Standings.getStandingsTable when provided; adds a spec asserting direct-path render equals var-path render.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
lua/wikis/commons/Widget/Standings.lua Adds support for rendering from a prebuilt StandingsModel instead of loading via page vars/LPDB.
lua/wikis/commons/Standings/Table.lua Producing-page render now uses the model returned by storage instead of re-reading via vars.
lua/wikis/commons/Standings/Storage.lua Reuses a single storage record for saves and returns a model-ready record + entries.
lua/spec/standings_model_spec.lua Adds an equality test ensuring direct-path rendering matches the existing var-path output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

local StringUtils = Lua.import('Module:StringUtils')

---@param props {pageName: string, standingsIndex: integer?}
---@param props {pageName: string?, standingsIndex: integer?, standings: StandingsModel?}
Comment on lines +21 to +26
local standings
if props.standings then
standings = props.standings
else
standings = Standings.getStandingsTable(props.pageName, props.standingsIndex)
end
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.

5 participants