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

refactor(match2): remove match.vod in favor of match.links.vod #4941

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions components/match2/commons/match.lua
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ end

---@param match table
function Match._prepareMatchRecordForStore(match)
match.links = match.links or {}
match.vod = match.vod or match.links.vod
match.dateexact = Logic.readBool(match.dateexact) and 1 or 0
match.finished = Logic.readBool(match.finished) and 1 or 0
match.match2bracketdata = match.match2bracketdata or match.bracketdata
Expand Down
3 changes: 1 addition & 2 deletions components/match2/commons/match_group_display_helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ components.
function DisplayHelper.defaultMatchHasDetails(match)
return match.dateIsExact
or (match.timestamp and match.timestamp ~= Date.defaultTimestamp)
or Logic.isNotEmpty(match.vod)
or not Table.isEmpty(match.links)
or Table.isNotEmpty(match.links)
or Logic.isNotEmpty(match.comment)
or 0 < #match.games
end
Expand Down
1 change: 0 additions & 1 deletion components/match2/commons/match_group_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,6 @@ function MatchGroupUtil.matchFromRecord(record)
timestamp = tonumber(Table.extract(extradata, 'timestamp')),
tournament = record.tournament,
type = nilIfEmpty(record.type) or 'literal',
vod = nilIfEmpty(record.vod),
walkover = walkover and walkover:lower() or nil,
winner = tonumber(record.winner),
}
Expand Down
6 changes: 0 additions & 6 deletions components/match2/commons/match_summary_base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -673,12 +673,6 @@ end
---@param footer MatchSummaryFooter
---@return MatchSummaryFooter
function MatchSummary.addVodsToFooter(match, footer)
if match.vod then
footer:addElement(VodLink.display{
vod = match.vod,
})
end

for gameIndex, game in ipairs(match.games) do
if game.vod then
footer:addElement(VodLink.display{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ function StarcraftMatchGroupInput.processMatch(match, options)
Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match))

match.stream = Streams.processStreams(match)
match.vod = Logic.nilIfEmpty(match.vod)

match.games = games
match.opponents = opponents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ function StarcraftFfaMatchGroupInput.processMatch(match, options)

match.links = MatchGroupInputUtil.getLinks(match)
match.stream = Streams.processStreams(match)
match.vod = Logic.nilIfEmpty(match.vod)

Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,7 @@ end
---@return boolean
function StarcraftMatchGroupUtil.matchHasDetails(match)
return match.dateIsExact
or String.isNotEmpty(match.vod)
or not Table.isEmpty(match.links)
or Table.isNotEmpty(match.links)
or String.isNotEmpty(match.comment)
or String.isNotEmpty(match.casters)
or 0 < #match.vetoes
Expand Down
2 changes: 1 addition & 1 deletion components/match2/wikis/ageofempires/match_legacy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function MatchLegacy.storeGames(match, match2)
game.extradata.gamenumber = gameIndex
game.extradata.mapmode = game2.extradata.mapmode
game.extradata.tournament = match.tournament
game.extradata.vodmatch = match.vod
game.extradata.vodmatch = match.links.vod
if game.mode == 'team' then
Array.forEach(opponents, function(opponent, opponentIndex)
-- opponent.players can have gaps
Expand Down
8 changes: 4 additions & 4 deletions components/match2/wikis/counterstrike/match_summary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ function CustomMatchSummary.addToFooter(match, footer)
end
end

if not Table.isEmpty(vods) or not Table.isEmpty(match.links) or not Logic.isEmpty(match.vod) then
if not Table.isEmpty(vods) or not Table.isEmpty(match.links) then
return CustomMatchSummary._createFooter(match, vods, secondVods)
end

Expand Down Expand Up @@ -257,12 +257,12 @@ function CustomMatchSummary._createFooter(match, vods, secondVods)

-- Match vod
if Table.isNotEmpty(secondVods[0]) then
addVodLink(nil, match.vod, 1)
addVodLink(nil, match.links.vod, 1)
Array.forEach(secondVods[0], function(vodlink, vodindex)
addVodLink(nil, vodlink, vodindex + 1)
end)
else
addVodLink(nil, match.vod, nil)
addVodLink(nil, match.links.vod, nil)
end

-- Game Vods
Expand All @@ -278,7 +278,7 @@ function CustomMatchSummary._createFooter(match, vods, secondVods)
end

if Table.isNotEmpty(match.links) then
if Logic.isNotEmpty(vods) or match.vod then
if Logic.isNotEmpty(vods) or match.links.vod then
footer:addElement(separator)
end
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ function CustomMatchGroupInput.processMatch(match, options)

match.stream = Streams.processStreams(match)

match.vod = Logic.emptyOr(match.vod, Variables.varDefault('vod'))

match.games = games
match.opponents = opponents

Expand Down
3 changes: 1 addition & 2 deletions components/match2/wikis/fighters/brkts_wiki_specific.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ local WikiSpecific = Table.copy(BaseWikiSpecific)
---@return boolean
function WikiSpecific.matchHasDetails(match)
return match.dateIsExact
or Logic.isNotEmpty(match.vod)
or not Table.isEmpty(match.links)
or Table.isNotEmpty(match.links)
or Logic.isNotEmpty(match.comment)
or 0 < #match.games
end
Expand Down
3 changes: 1 addition & 2 deletions components/match2/wikis/warcraft/brkts_wiki_specific.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ end)
---@return boolean
function WikiSpecific.matchHasDetails(match)
return match.dateIsExact
or match.vod
or not Table.isEmpty(match.links)
or Table.isNotEmpty(match.links)
or match.comment
or match.casters
or 0 < #match.vetoes
Expand Down
4 changes: 2 additions & 2 deletions components/match_table/commons/match_table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,8 @@ end
---@return {index: number, link: string}[]
function MatchTable:vodsFromRecord(record)
local vods = {}
if String.nilIfEmpty(record.vod) then
vods = {{index = 0, link = record.vod}}
if String.nilIfEmpty(record.links.vod) then
Copy link
Collaborator

@hjpalpha hjpalpha Oct 22, 2024

Choose a reason for hiding this comment

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

links is not retrieved, you need to adjust the query param in the query calls too (lines 290-291)

vods = {{index = 0, link = record.links.vod}}
end

Array.forEach(record.match2games, function(game, gameIndex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ function Details:countdown(matchPageIcon)

local gameVods = Array.map(Array.map(match.match2games, Operator.property('vod')), makeVod)

countdownDisplay:node(makeVod(match.vod))
countdownDisplay:node(makeVod(match.links.vod))
Copy link
Collaborator

@hjpalpha hjpalpha Oct 22, 2024

Choose a reason for hiding this comment

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

need to adjust DEFAULT_QUERY_COLUMNS too
and check if there are places overwriting that default somewhere

and also infobox player on sc2

Array.forEach(gameVods, function(vod)
countdownDisplay:node(vod)
end)
Expand Down
2 changes: 1 addition & 1 deletion standard/links/commons/links.lua
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ local PREFIXES = {
player = 'https://www.vlr.gg/player/',
match = 'https://vlr.gg/',
},
vod = {''},
vod = {'', match = ''},
weibo = {'https://weibo.com/'},
wl = {match = 'https://www.winstonslab.com/matches/match.php?id='},
yandexefir = {'https://yandex.ru/efir?stream_channel='},
Expand Down
Loading