From 8f4a4dde07431a68fe284a2e176c8938dd6d9e89 Mon Sep 17 00:00:00 2001 From: Rikard Blixt Date: Tue, 15 Oct 2024 18:02:53 +0200 Subject: [PATCH] refactor(match2): standardize link parsing --- .../match2/commons/match_group_input_util.lua | 10 ++++++++++ .../rainbowsix/match_group_input_custom.lua | 19 +------------------ standard/links/commons/links.lua | 14 +++++++++++++- .../wikis/rainbowsix/links_custom_data.lua | 1 + 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/components/match2/commons/match_group_input_util.lua b/components/match2/commons/match_group_input_util.lua index 29ed9aa5350..dc27bfeb82b 100644 --- a/components/match2/commons/match_group_input_util.lua +++ b/components/match2/commons/match_group_input_util.lua @@ -20,6 +20,7 @@ local PageVariableNamespace = require('Module:PageVariableNamespace') local String = require('Module:StringUtils') local Table = require('Module:Table') +local Links = Lua.import('Module:Links') local MatchGroupUtil = Lua.import('Module:MatchGroup/Util') local PlayerExt = Lua.import('Module:Player/Ext/Custom') @@ -1034,6 +1035,15 @@ function MatchGroupInputUtil.prefixPartcipants(opponentIndex) end end +---@param match table +---@return { [string]: string } +function MatchGroupInputUtil.getLinks(match) + local links = Links.transform(match) + return Table.map(links, function(value, key) + return key, Links.makeFullLink(key, value, 'match') + end) +end + --- Warning, both match and standalone match may be mutated ---@param match table ---@param standaloneMatch table diff --git a/components/match2/wikis/rainbowsix/match_group_input_custom.lua b/components/match2/wikis/rainbowsix/match_group_input_custom.lua index 40b264ce16e..7c61fde0ba3 100644 --- a/components/match2/wikis/rainbowsix/match_group_input_custom.lua +++ b/components/match2/wikis/rainbowsix/match_group_input_custom.lua @@ -71,7 +71,7 @@ function CustomMatchGroupInput.processMatch(match, options) Table.mergeInto(match, MatchGroupInputUtil.getTournamentContext(match)) match.stream = Streams.processStreams(match) - match.links = MatchFunctions.getLinks(match) + match.links = MatchGroupInputUtil.getLinks(match) match.games = games match.opponents = opponents @@ -138,23 +138,6 @@ function MatchFunctions.calculateMatchScore(maps) end end ----@param match table ----@return table -function MatchFunctions.getLinks(match) - return { - stats = match.stats, - siegegg = match.siegegg and 'https://siege.gg/matches/' .. match.siegegg or nil, - opl = match.opl and 'https://www.opleague.eu/match/' .. match.opl or nil, - esl = match.esl and 'https://play.eslgaming.com/match/' .. match.esl or nil, - faceit = match.faceit and 'https://www.faceit.com/en/rainbow_6/room/' .. match.faceit or nil, - lpl = match.lpl and 'https://old.letsplay.live/match/' .. match.lpl or nil, - r6esports = match.r6esports - and 'https://www.ubisoft.com/en-us/esports/rainbow-six/siege/match/' .. match.r6esports or nil, - challengermode = match.challengermode and 'https://www.challengermode.com/games/' .. match.challengermode or nil, - ebattle = match.ebattle and 'https://www.ebattle.gg/turnier/match/' .. match.ebattle or nil, - } -end - ---@param match table ---@return table function MatchFunctions.getExtraData(match) diff --git a/standard/links/commons/links.lua b/standard/links/commons/links.lua index 2dd93fa561a..cda19640fbf 100644 --- a/standard/links/commons/links.lua +++ b/standard/links/commons/links.lua @@ -50,7 +50,8 @@ local PREFIXES = { challengermode = { 'https://www.challengermode.com/tournaments/', player = 'https://www.challengermode.com/users/', - team = 'https://www.challengermode.com/teams/' + team = 'https://www.challengermode.com/teams/', + match = 'https://www.challengermode.com/games/', }, challonge = { '', @@ -76,6 +77,7 @@ local PREFIXES = { douyin = {'https://live.douyin.com/'}, douyin_page = {'https://v.douyin.com/'}, douyu = {'https://www.douyu.com/'}, + ebattle = {match = 'https://www.ebattle.gg/turnier/match/'}, esea = { 'https://play.esea.net/events/', player = 'https://play.esea.net/users/', @@ -86,6 +88,7 @@ local PREFIXES = { '', team = 'https://play.eslgaming.com/team/', player = 'https://play.eslgaming.com/player/', + match = 'https://play.eslgaming.com/match/', }, esportal = {'https://esportal.com/tournament/'}, etf2l = { @@ -132,6 +135,7 @@ local PREFIXES = { 'https://gg.letsplay.live/tournament/', team = 'https://gg.letsplay.live/view-team/', player = 'https://gg.letsplay.live/profile/view-stats/', + match = 'https://old.letsplay.live/match/', }, linkedin = {'https://www.linkedin.com/in/'}, loco = {'https://loco.gg/streamers/'}, @@ -147,12 +151,18 @@ local PREFIXES = { player = 'https://nwc3l.com/profile/', }, openrec = {'https://www.openrec.tv/live/'}, + opl = { + match = 'https://www.opleague.eu/match/' + }, osu = { 'https://osu.ppy.sh/', player = 'https://osu.ppy.sh/users/', }, patreon = {'https://www.patreon.com/'}, playlist = {''}, + r6esports = { + match = 'https://www.ubisoft.com/en-us/esports/rainbow-six/siege/match/', + }, reddit = {'https://www.reddit.com/user/'}, replay = {''}, rgl = { @@ -168,6 +178,7 @@ local PREFIXES = { 'https://siege.gg/competitions/', team = 'https://siege.gg/teams/', player = 'https://siege.gg/players/', + match = 'https://siege.gg/matches/', }, sk = {'https://sk-gaming.com/member/'}, smashboards = {'https://smashboards.com/'}, @@ -185,6 +196,7 @@ local PREFIXES = { pubsteam = {'https://steamcommunity.com/groups/'}, spotify = {'https://open.spotify.com/'}, steamalternative = {'https://steamcommunity.com/profiles/'}, + stats = {''}, stratz = { 'https://stratz.com/leagues/', player = 'https://stratz.com/players/', diff --git a/standard/links/wikis/rainbowsix/links_custom_data.lua b/standard/links/wikis/rainbowsix/links_custom_data.lua index c4ef07a72dd..30303559c50 100644 --- a/standard/links/wikis/rainbowsix/links_custom_data.lua +++ b/standard/links/wikis/rainbowsix/links_custom_data.lua @@ -12,6 +12,7 @@ return { 'https://www.faceit.com/en/championship/', team = 'https://www.faceit.com/en/teams/', player = 'https://www.faceit.com/en/players/', + match = 'https://www.faceit.com/en/rainbow_6/room/', } }, }