Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(match table): use status instead of resulttype and walkover #5085

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions components/game_table/commons/game_table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ local VodLink = require('Module:VodLink')

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

local NOT_PLAYED = 'np'
local NOT_PLAYED = 'notplayed'
local SCORE_CONCAT = ' : '

---@class GameTableMatch: MatchTableMatch
Expand All @@ -31,7 +31,7 @@ end)
---@return match2game?
function GameTable:gameFromRecord(game)
if self.countGames == self.config.limit then return nil end
if game.resulttype == NOT_PLAYED or Logic.isEmpty(game.winner) then
if game.status == NOT_PLAYED or Logic.isEmpty(game.winner) then
return nil
end

Expand Down
5 changes: 2 additions & 3 deletions components/game_table/commons/game_table_character.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ local Comparator = Condition.Comparator
local BooleanOperator = Condition.BooleanOperator
local ColumnName = Condition.ColumnName

local DRAW = 'draw'
local CHARACTER_MODE = 'character'
local SCORE_CONCAT = ' : '

Expand Down Expand Up @@ -246,7 +245,7 @@ function CharacterGameTable:resultFromRecord(record)
opponent = record.match2opponents[1],
vs = record.match2opponents[2],
winner = tonumber(record.winner),
resultType = record.resultType,
status = record.status,
countGames = true,
}
end
Expand All @@ -260,7 +259,7 @@ function CharacterGameTable:statsFromMatches()
Array.forEach(match.games, function (game, index)
local winner = tonumber(game.winner)

if game.resulttype == DRAW then
if winner == 0 then
totalGames.d = totalGames.d + 1
elseif game.pickedBy == winner then
totalGames.w = totalGames.w + 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function CustomPlayer:_getMatchupData(player)
'[[finished::1]]', -- only finished matches
'[[winner::!]]', -- expect a winner
'[[walkover::]]', -- exclude default wins/losses
'[[resulttype::!np]]', -- i.e. ignore not played matches
'[[status::!notplayed]]', -- i.e. ignore not played matches
'[[date::!' .. DateExt.defaultDate .. ']]', --i.e. wrongly set up
'([[opponent::' .. player .. ']] OR [[opponent::' .. playerWithoutUnderscore .. ']])'
}, ' AND '),
Expand Down
18 changes: 10 additions & 8 deletions components/match_table/commons/match_table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ local BooleanOperator = Condition.BooleanOperator
local ColumnName = Condition.ColumnName

local UTC = 'UTC'
local DRAW = 'draw'
local RESULT_TYPE_DEFAULT = 'default'
local INVALID_TIER_DISPLAY = 'Undefined'
local INVALID_TIER_SORT = 'ZZ'
local SCORE_STATUS = 'S'
Expand Down Expand Up @@ -89,8 +87,9 @@ local SCORE_CONCAT = ' : '
---@field opponent match2opponent
---@field vs match2opponent
---@field winner number
---@field resultType string?
---@field status string?
---@field countGames boolean
---@field isWalkover boolean

---@class MatchTable
---@operator call(table): MatchTable
Expand Down Expand Up @@ -288,7 +287,7 @@ function MatchTable:query()
conditions = self:buildConditions(),
order = 'date desc',
query = 'match2opponents, match2games, date, dateexact, icon, icondark, liquipediatier, game, type, '
.. 'liquipediatiertype, tournament, pagename, tickername, vod, winner, walkover, resulttype, extradata',
.. 'liquipediatiertype, tournament, pagename, tickername, vod, winner, walkover, status, extradata',
}, function(match)
table.insert(self.matches, self:matchFromRecord(match) or nil)
end, self.config.limit)
Expand Down Expand Up @@ -357,7 +356,7 @@ end
function MatchTable:buildAdditionalConditions()
local args = self.args
local conditions = ConditionTree(BooleanOperator.all)
:add{ConditionNode(ColumnName('resulttype'), Comparator.neq, 'np')}
:add{ConditionNode(ColumnName('status'), Comparator.neq, 'notplayed')}
local hasAdditionalConditions = false

local getOrCondition = function(lpdbKey, input)
Expand Down Expand Up @@ -467,8 +466,11 @@ function MatchTable:resultFromRecord(record)
opponent = record.match2opponents[indexes[1]],
vs = record.match2opponents[indexes[2]],
winner = winner,
resultType = record.resultType,
status = record.status,
countGames = countGames,
isWalkover = Array.any(record.match2opponents, function(opponent)
return opponent.status == 'DQ' or opponent.status == 'FF'
end)
}

return result
Expand All @@ -490,9 +492,9 @@ function MatchTable:statsFromMatches()
end

Array.forEach(self.matches, function(match)
if match.result.resultType == RESULT_TYPE_DEFAULT then
if match.result.isWalkover then
return
elseif match.result.resultType == DRAW then
elseif match.result.winner == 0 then
totalMatches.d = totalMatches.d + 1
elseif match.result.winner == 1 then
totalMatches.w = totalMatches.w + 1
Expand Down
Loading