Skip to content

Commit

Permalink
refactor(match2): standardize link parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Rathoz committed Oct 15, 2024
1 parent a219cab commit 8f4a4dd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
10 changes: 10 additions & 0 deletions components/match2/commons/match_group_input_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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
Expand Down
19 changes: 1 addition & 18 deletions components/match2/wikis/rainbowsix/match_group_input_custom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 13 additions & 1 deletion standard/links/commons/links.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
'',
Expand All @@ -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/',
Expand All @@ -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 = {
Expand Down Expand Up @@ -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/'},
Expand All @@ -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 = {
Expand All @@ -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/'},
Expand All @@ -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/',
Expand Down
1 change: 1 addition & 0 deletions standard/links/wikis/rainbowsix/links_custom_data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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/',
}
},
}

0 comments on commit 8f4a4dd

Please sign in to comment.