Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lua/wikis/commons/TeamParticipants/Parse/Wiki.lua
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ function TeamParticipantsWikiParser.parseParticipant(input, defaultDate)

local aliases = Array.parseCommaSeparatedString(input.aliases, ';')
table.insert(aliases, Opponent.toName(opponent))
table.insert(aliases, opponent.template)
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.

This should not be necessary with the changes to TT.getPageName, as `Opponent.toName uses that, right?

Suggested change
table.insert(aliases, opponent.template)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

GetPageName works the same as before, other than it reuses a new function

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Template names are lower case as well, while a pagename is not necessarily

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.

GetPageName works the same as before, other than it reuses a new function

The diff made it easy to misread, sorry.

However, if toName still uses redirects resolved page names, this would still run into issue when e.g. enriching placement data in TeamParticipants


Comment thread
Rathoz marked this conversation as resolved.
return {
opponent = opponent,
Expand Down
5 changes: 4 additions & 1 deletion lua/wikis/commons/TeamParticipants/Repository.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,16 @@ end
---@param participant TeamParticipant
function TeamParticipantsRepository.setPageVars(participant)
Array.forEach(participant.aliases or {}, function(teamTemplate)
local teamName = TeamTemplate.getPageName(teamTemplate)
local teamName = TeamTemplate.getPageNameNoRedirect(teamTemplate)
if not teamName then
return
end
local teamNameRedirected = mw.ext.TeamLiquidIntegration.resolve_redirect(teamName)
local teamPrefixes = {
teamName:gsub('_', ' '),
teamName:gsub(' ', '_'),
teamNameRedirected:gsub('_', ' '),
teamNameRedirected:gsub(' ', '_'),
}
local playerCount, staffCount = 0, 0
Array.forEach(participant.opponent.players or {}, function(player)
Expand Down
22 changes: 19 additions & 3 deletions lua/wikis/commons/TeamTemplate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,31 @@ function TeamTemplate.getIcon(template)
end

--[[
Returns the resolved page name of a team template that has been resolved to a
Returns the page name with resolved redirects of a team template that has been resolved to a
date. Returns nil if the team does not exist, or if the page is not specified.
]]
---@param resolvedTemplate string
---@return string|nil
TeamTemplate.getPageName = FnUtil.memoize(function(resolvedTemplate)
local page = TeamTemplate.getPageNameNoRedirect(resolvedTemplate)
if not page then
return
end
return Page.applyUnderScoresIfEnforced(mw.ext.TeamLiquidIntegration.resolve_redirect(page))
end)

--[[
Returns the raw page name of a team template that has been resolved to a
date. Returns nil if the team does not exist, or if the page is not specified.
]]
---@param resolvedTemplate string
---@return string|nil
TeamTemplate.getPageNameNoRedirect = FnUtil.memoize(function(resolvedTemplate)
local raw = TeamTemplate.getRawOrNil(resolvedTemplate)
local pageName = raw and mw.ext.TeamLiquidIntegration.resolve_redirect(raw.page) or nil
return Page.applyUnderScoresIfEnforced(pageName)
if not raw then
return
end
return Page.applyUnderScoresIfEnforced(raw.page)
end)

--[[
Expand Down
Loading