From 40b67e46541c12c4fda8e3f4d96200ff72cc22c7 Mon Sep 17 00:00:00 2001 From: hjpalpha Date: Wed, 16 Oct 2024 07:47:17 +0200 Subject: [PATCH 1/6] add `postponed` as allowed np input (used on cs) --- components/match2/commons/match_group_input_util.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/components/match2/commons/match_group_input_util.lua b/components/match2/commons/match_group_input_util.lua index 29ed9aa5350..cd25dea848a 100644 --- a/components/match2/commons/match_group_input_util.lua +++ b/components/match2/commons/match_group_input_util.lua @@ -55,6 +55,7 @@ local NOT_PLAYED_INPUTS = { 'np', 'canceled', 'cancelled', + 'postponed', } MatchGroupInputUtil.DEFAULT_ALLOWED_VETOES = { From 6c40b4ba9f96dc07160b4616e166732d89ee639f Mon Sep 17 00:00:00 2001 From: hjpalpha Date: Wed, 16 Oct 2024 07:54:38 +0200 Subject: [PATCH 2/6] fix status/finished processing on cs --- .../counterstrike/match_group_input_custom.lua | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/components/match2/wikis/counterstrike/match_group_input_custom.lua b/components/match2/wikis/counterstrike/match_group_input_custom.lua index 7ef6c6249f8..918df24a8cb 100644 --- a/components/match2/wikis/counterstrike/match_group_input_custom.lua +++ b/components/match2/wikis/counterstrike/match_group_input_custom.lua @@ -39,6 +39,11 @@ local CustomMatchGroupInput = {} ---@param options table? ---@return table function CustomMatchGroupInput.processMatch(match, options) + match.status = Logic.emptyOr(match.status, Variables.varDefault('tournament_status'), match.finished) + if (not Logic.readBool(match.finished)) and Logic.isNotEmpty(match.status) then + match.finished = match.status + end + local finishedInput = match.finished --[[@as string?]] local winnerInput = match.winner --[[@as string?]] @@ -76,7 +81,6 @@ function CustomMatchGroupInput.processMatch(match, options) match.mode = Logic.emptyOr(match.mode, Variables.varDefault('tournament_mode', 'team')) match.publishertier = Logic.emptyOr(match.publishertier, Variables.varDefault('tournament_valve_tier')) - match.status = Logic.emptyOr(match.status, Variables.varDefault('tournament_status')) Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) @@ -198,14 +202,6 @@ function MatchFunctions.getLinks(match, maps) end) end ----@param match table ----@return string? -function MatchFunctions.getMatchStatus(match) - if match.resulttype == 'np' then - return Logic.emptyOr(match.status, Variables.varDefault('tournament_status')) - end -end - ---@param name string? ---@param year string|osdate ---@return number @@ -253,7 +249,7 @@ end function MatchFunctions.getExtraData(match, opponents) return { mapveto = MatchGroupInputUtil.getMapVeto(match), - status = MatchFunctions.getMatchStatus(match), + status = match.resulttype == MatchGroupInputUtil.RESULT_TYPE.NOT_PLAYED and match.status or nil, overturned = Logic.isNotEmpty(match.overturned), featured = MatchFunctions.isFeatured(match, opponents), hidden = Logic.readBool(Variables.varDefault('match_hidden')) From 66b2dac06c3a2f6a429c1969770f1c6d42bbaa17 Mon Sep 17 00:00:00 2001 From: hjpalpha <75081997+hjpalpha@users.noreply.github.com> Date: Thu, 17 Oct 2024 10:26:03 +0200 Subject: [PATCH 3/6] Update components/match2/commons/match_group_input_util.lua --- components/match2/commons/match_group_input_util.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/components/match2/commons/match_group_input_util.lua b/components/match2/commons/match_group_input_util.lua index cd25dea848a..29ed9aa5350 100644 --- a/components/match2/commons/match_group_input_util.lua +++ b/components/match2/commons/match_group_input_util.lua @@ -55,7 +55,6 @@ local NOT_PLAYED_INPUTS = { 'np', 'canceled', 'cancelled', - 'postponed', } MatchGroupInputUtil.DEFAULT_ALLOWED_VETOES = { From 4a1c3d7011eed0eb3733d407e7b9568e9d49c42e Mon Sep 17 00:00:00 2001 From: hjpalpha Date: Mon, 21 Oct 2024 10:47:45 +0200 Subject: [PATCH 4/6] do not overwrite input values directly --- .../match_group_input_custom.lua | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/components/match2/wikis/counterstrike/match_group_input_custom.lua b/components/match2/wikis/counterstrike/match_group_input_custom.lua index 918df24a8cb..6f032360f6b 100644 --- a/components/match2/wikis/counterstrike/match_group_input_custom.lua +++ b/components/match2/wikis/counterstrike/match_group_input_custom.lua @@ -39,12 +39,14 @@ local CustomMatchGroupInput = {} ---@param options table? ---@return table function CustomMatchGroupInput.processMatch(match, options) - match.status = Logic.emptyOr(match.status, Variables.varDefault('tournament_status'), match.finished) - if (not Logic.readBool(match.finished)) and Logic.isNotEmpty(match.status) then - match.finished = match.status - end - - local finishedInput = match.finished --[[@as string?]] + ---@type string + local finishedInput = tostring(Logic.nilOr( + Logic.readBoolOrNil(match.finished), + Logic.nilIfEmpty(match.status), + Variables.varDefault('tournament_status'), + match.finished, + '' + )) local winnerInput = match.winner --[[@as string?]] Table.mergeInto(match, MatchGroupInputUtil.readDate(match.date)) @@ -89,7 +91,7 @@ function CustomMatchGroupInput.processMatch(match, options) match.games = games match.opponents = opponents - match.extradata = MatchFunctions.getExtraData(match, opponents) + match.extradata = MatchFunctions.getExtraData(match, opponents, finishedInput) return match end @@ -245,11 +247,12 @@ end ---@param match table ---@param opponents table[] +---@param finishedInput string ---@return table -function MatchFunctions.getExtraData(match, opponents) +function MatchFunctions.getExtraData(match, opponents, finishedInput) return { mapveto = MatchGroupInputUtil.getMapVeto(match), - status = match.resulttype == MatchGroupInputUtil.RESULT_TYPE.NOT_PLAYED and match.status or nil, + status = match.resulttype == MatchGroupInputUtil.RESULT_TYPE.NOT_PLAYED and Logic.nilIfEmpty(finishedInput) or nil, overturned = Logic.isNotEmpty(match.overturned), featured = MatchFunctions.isFeatured(match, opponents), hidden = Logic.readBool(Variables.varDefault('match_hidden')) From 3cbb196130f6c2fdcc56fefd84d6c7001e250c53 Mon Sep 17 00:00:00 2001 From: hjpalpha Date: Mon, 21 Oct 2024 10:50:04 +0200 Subject: [PATCH 5/6] couldn't find usage in matches so lets kick it --- .../match2/wikis/counterstrike/match_group_input_custom.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/components/match2/wikis/counterstrike/match_group_input_custom.lua b/components/match2/wikis/counterstrike/match_group_input_custom.lua index 6f032360f6b..bb09d97a454 100644 --- a/components/match2/wikis/counterstrike/match_group_input_custom.lua +++ b/components/match2/wikis/counterstrike/match_group_input_custom.lua @@ -42,7 +42,6 @@ function CustomMatchGroupInput.processMatch(match, options) ---@type string local finishedInput = tostring(Logic.nilOr( Logic.readBoolOrNil(match.finished), - Logic.nilIfEmpty(match.status), Variables.varDefault('tournament_status'), match.finished, '' From 5887529f9739a67211bcbbff8af5790a396f03f5 Mon Sep 17 00:00:00 2001 From: hjpalpha Date: Tue, 22 Oct 2024 08:00:01 +0200 Subject: [PATCH 6/6] as per discussion --- .../wikis/counterstrike/match_group_input_custom.lua | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/components/match2/wikis/counterstrike/match_group_input_custom.lua b/components/match2/wikis/counterstrike/match_group_input_custom.lua index bb09d97a454..9e116186a2e 100644 --- a/components/match2/wikis/counterstrike/match_group_input_custom.lua +++ b/components/match2/wikis/counterstrike/match_group_input_custom.lua @@ -39,13 +39,7 @@ local CustomMatchGroupInput = {} ---@param options table? ---@return table function CustomMatchGroupInput.processMatch(match, options) - ---@type string - local finishedInput = tostring(Logic.nilOr( - Logic.readBoolOrNil(match.finished), - Variables.varDefault('tournament_status'), - match.finished, - '' - )) + local finishedInput = Logic.nilIfEmpty(match.finished) or Variables.varDefault('tournament_status') --[[@as string?]] local winnerInput = match.winner --[[@as string?]] Table.mergeInto(match, MatchGroupInputUtil.readDate(match.date)) @@ -246,12 +240,12 @@ end ---@param match table ---@param opponents table[] ----@param finishedInput string +---@param finishedInput string? ---@return table function MatchFunctions.getExtraData(match, opponents, finishedInput) return { mapveto = MatchGroupInputUtil.getMapVeto(match), - status = match.resulttype == MatchGroupInputUtil.RESULT_TYPE.NOT_PLAYED and Logic.nilIfEmpty(finishedInput) or nil, + status = match.resulttype == MatchGroupInputUtil.RESULT_TYPE.NOT_PLAYED and finishedInput or nil, overturned = Logic.isNotEmpty(match.overturned), featured = MatchFunctions.isFeatured(match, opponents), hidden = Logic.readBool(Variables.varDefault('match_hidden'))