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
31 changes: 20 additions & 11 deletions lua/wikis/commons/AutomaticPointsTable.lua
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,10 @@ function AutomaticPointsTable:parseOpponents(args, tournaments)
background = parsedArgs.bg,
note = parsedArgs.note,
}
assert(parsedOpponent.opponent.type == Opponent.team)
assert(not Opponent.isTbd(parsedOpponent.opponent))
local aliases = self:parseAliases(parsedArgs, parsedOpponent.opponent, #tournaments)
local resolveDate = DateExt.readTimestamp(args.date) or DateExt.getContextualDateOrNow()
parsedOpponent.opponent = Opponent.resolve(parsedOpponent.opponent, resolveDate, {syncPlayer = true})

parsedOpponent.results = Array.map(tournaments, function (tournament, tournamentIndex)
local manualPoints = parsedArgs['points' .. tournamentIndex]
Expand All @@ -172,7 +173,7 @@ function AutomaticPointsTable:parseOpponents(args, tournaments)
}, self:parseDeduction(parsedArgs, tournament, tournamentIndex))
end

local queriedPoints = self:queryPlacement(aliases[tournamentIndex], tournament)
local queriedPoints = self:queryPlacement(aliases[tournamentIndex], parsedOpponent.opponent, tournament)

if not queriedPoints then
return {}
Expand Down Expand Up @@ -203,14 +204,21 @@ end
---@return string[][]
function AutomaticPointsTable:parseAliases(args, opponent, tournamentCount)
local aliases = {}
local lastAliases = TeamTemplate.queryHistoricalNames(Opponent.toName(opponent))

for index = 1, tournamentCount do
if String.isNotEmpty(args['alias' .. index]) then
lastAliases = TeamTemplate.queryHistoricalNames(args['alias' .. index])
local name = Opponent.toName(opponent)
if (opponent.type == Opponent.team) then
local lastAliases = TeamTemplate.queryHistoricalNames(name)
for index = 1, tournamentCount do
if String.isNotEmpty(args['alias' .. index]) then
lastAliases = TeamTemplate.queryHistoricalNames(args['alias' .. index])
end
aliases[index] = lastAliases
end
else
for index = 1, tournamentCount do
aliases[index] = {name}
end
aliases[index] = lastAliases
end

return aliases
end

Expand All @@ -236,12 +244,13 @@ function AutomaticPointsTable:parseDeduction(args, tournament, tournamentIndex)
end

---@param aliases string[]
---@param opponent standardOpponent
---@param tournament StandardTournament
function AutomaticPointsTable:queryPlacement(aliases, tournament)
function AutomaticPointsTable:queryPlacement(aliases, opponent, tournament)
local conditionType = (opponent.type == 'team') and 'opponenttemplate' or 'opponentname'
local conditions = ConditionTree(BooleanOperator.all):add{
ConditionNode(ColumnName('parent'), Comparator.eq, tournament.pageName),
ConditionNode(ColumnName('opponenttype'), Comparator.eq, Opponent.team),
Condition.Util.anyOf(ColumnName('opponenttemplate'), aliases),
Condition.Util.anyOf(ColumnName(conditionType), aliases),
}
local result = mw.ext.LiquipediaDB.lpdb('placement', {
conditions = tostring(conditions),
Expand Down
7 changes: 5 additions & 2 deletions lua/wikis/commons/Widget/AutomaticPointsTable.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function AutomaticPointsTableWidget:createHeader()
classes = {'divHeaderRow', 'diagonal'},
children = WidgetUtil.collect(
AutomaticPointsTableWidget._createHeaderCell('Ranking','ranking'),
AutomaticPointsTableWidget._createHeaderCell('Team', 'team'),
AutomaticPointsTableWidget._createHeaderCell('Participant', 'participant'),
AutomaticPointsTableWidget._createHeaderCell('Total Points'),
Array.flatMap(tournaments, function (tournament)
return {
Expand Down Expand Up @@ -137,7 +137,10 @@ function AutomaticPointsTableWidget:createRow(opponent, opponentIndex)
AutomaticPointsTableWidget._createRowCell{
additionalClasses = {'name-cell'},
background = opponent.background,
children = OpponentDisplay.BlockOpponent{opponent = opponent.opponent, note = opponent.note},
children = OpponentDisplay.BlockOpponent{opponent = opponent.opponent,
note = opponent.note,
showPlayerTeam = true
},
},
self:_createTotalPointsCell(opponent),
Array.flatMap(opponent.results, function (result, resultIndex)
Expand Down
2 changes: 1 addition & 1 deletion stylesheets/commons/AutomaticPointsTable.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Author(s): XtratoS
transform: translate( 50.5px, 79px ) rotate( -45deg );
}

.automatic-points-table .diagonal-header-div-cell.team {
.automatic-points-table .diagonal-header-div-cell.participant {
min-width: 225px;
max-width: 225px;
transform: translate( 212px, 12.5px ) rotate( -45deg );
Expand Down
Loading