[checked revision] | [checked revision] |
No edit summary |
No edit summary |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | local |
+ | local util_args = require('Module:ArgsUtil') |
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
+ | local util_tournament = require('Module:TournamentUtil') |
||
+ | local util_vars = require('Module:VarsUtil') |
||
⚫ | |||
⚫ | |||
⚫ | |||
+ | local Results = require('Module:TeamResultsAbstract'):extends() |
||
⚫ | |||
− | if frame == mw.getCurrentFrame() then |
||
⚫ | |||
− | else |
||
− | frame = mw.getCurrentFrame() |
||
⚫ | |||
− | |||
− | local team = args[1] or tostring(mw.title.getCurrentTitle()) |
||
− | local tournamentType = args.type or '' |
||
− | local limit = args[3] or 5000 |
||
+ | function Results:init() |
||
⚫ | |||
− | + | self:super('init', 'Team') |
|
+ | self.limitOverviewpage = 10 |
||
⚫ | |||
+ | self.limitEverything = 500 |
||
⚫ | |||
+ | self.COLUMNS = { 'Game', 'Date', 'PlaceDisplay', 'PrizeDisplay', 'Tournament', 'Roster' } |
||
− | |||
⚫ | |||
− | local teamlink = m_team.teamlinkname(team) |
||
⚫ | |||
− | |||
− | tbl:addClass("wikitable sortable"):css("font-size","90%") |
||
− | :tag("tr") |
||
− | :tag("th"):css({ background = "#E6E6E6", border = "1px solid black" }):attr("colspan","30") |
||
− | :wikitext('Recent Tournament Results [[' .. teamlink .. '/Tournament Results|(View All)]]'):done() |
||
− | :done() |
||
− | :tag("tr") |
||
− | :tag("th"):css("width","60"):wikitext("Game"):done() |
||
− | :tag("th"):css("width","60"):wikitext("Date"):done() |
||
− | :tag("th"):css("width","60"):wikitext("Place"):done() |
||
− | :tag("th"):css("width","80"):wikitext("Prize"):done() |
||
− | :tag("th"):css("width","250"):wikitext("Event"):done() |
||
− | --:tag("th"):css("width","150"):wikitext("Last Result"):done() |
||
− | :tag("th"):wikitext("Roster"):done() |
||
− | :done() |
||
− | |||
− | local result = p.load(teamlink, tournamentType, limit) |
||
− | |||
− | for _,row in ipairs(result) do |
||
− | tr = tbl:tag("tr") |
||
− | tr:tag('td'):wikitext(Game{row['Game']}):done() |
||
− | tr:tag("td"):wikitext(row["Date"]):done() -- Need to format this right still |
||
− | :node(placement.makeNode(row.Place)) |
||
− | :tag("td"):wikitext(row["PrizeMarkup"]):done() |
||
− | tdEvent = tr:tag("td"):wikitext(League{row["League"],"onlyimage"} .. " [[" .. row["EventLink"] .. "|" .. row["Event"]) |
||
− | if row["Phase"] ~= "" then |
||
− | tdEvent:wikitext(" - " .. row["Phase"]) |
||
⚫ | |||
− | tdEvent:wikitext("]]"):done() |
||
− | |||
− | teammates = {} |
||
− | teammatenames = mw.text.split(row["RosterNames"],",",true) |
||
− | teammatelinks = mw.text.split(row["RosterLinks"],",",true) |
||
− | roles = mw.text.split(row["Roles"],",",true) |
||
− | |||
− | if teammatelinks[1] ~= "" then |
||
− | for index,teammatelink in ipairs(teammatelinks) do |
||
− | teammates[#teammates+1] = (roles[index] or '') .. " [[" .. teammatelink .. "|" .. teammatenames[index] .. "]]" |
||
− | end |
||
− | end |
||
− | tr:tag("td"):wikitext(table.concat(teammates, " • ")) |
||
− | |||
− | if row["Prize"] ~= "" then |
||
− | earnings[row["PrizeUnit"]] = (earnings[row["PrizeUnit"]] or 0) + tonumber(row["Prize"],10) |
||
− | end |
||
− | tr:done() |
||
− | end |
||
− | |||
− | td = tbl:tag("tr") |
||
− | :tag("th"):attr("colspan","30"):wikitext("Total Prize: ") |
||
− | |||
− | local earningstable = {} |
||
− | |||
− | for currency, amount in pairs(earnings) do |
||
− | earningstable[#earningstable+1] = currency .. " " .. mw.getLanguage('en'):formatNum(amount) |
||
− | end |
||
− | |||
− | td:wikitext(table.concat(earningstable," • ")):done() |
||
− | |||
− | text = tostring(tbl) |
||
− | |||
− | return text |
||
end |
end |
||
⚫ | |||
− | function p.shortList(frame) |
||
− | if frame == mw.getCurrentFrame() then |
||
⚫ | |||
− | else |
||
− | frame = mw.getCurrentFrame() |
||
− | end |
||
− | |||
− | local team = args[1] or tostring(mw.title.getCurrentTitle()) |
||
− | local tournamentType = args[2] or 'Offline' |
||
− | local limit = args[3] or 5 |
||
⚫ | |||
⚫ | |||
− | local |
+ | local args = util_args.merge() |
+ | return Results():run(args) |
||
⚫ | |||
⚫ | |||
⚫ | |||
+ | function Results:getSubject(args) |
||
− | local tbl = mw.html.create('table') |
||
− | + | return args[1] and m_team.teamlinkname(args[1]) or mw.title.getCurrentTitle().baseText |
|
⚫ | |||
⚫ | |||
+ | function Results:getSubjectWhereCondition(args, subject) |
||
− | tbl:addClass("wikitable sortable"):css("font-size","90%") |
||
+ | return ('Res.Team="%s"'):format(subject) |
||
− | :tag("tr") |
||
− | :tag("th"):css({ background = "#E6E6E6", border = "1px solid black" }):attr("colspan","30") |
||
− | :wikitext('Recent Tournament Results [[' .. teamlink .. '/Tournament Results|(View All)]]'):done() |
||
− | :done() |
||
− | :tag("tr") |
||
− | :tag("th"):css("width","60"):wikitext("Game"):done() |
||
− | :tag("th"):css("width","60"):wikitext("Date"):done() |
||
− | :tag("th"):css("width","60"):wikitext("Place"):done() |
||
− | :tag("th"):css("width","80"):wikitext("Prize"):done() |
||
− | :tag("th"):css("width","250"):wikitext("Event"):done() |
||
− | --:tag("th"):css("width","150"):wikitext("Last Result"):done() |
||
− | :tag("th"):wikitext("Roster"):done() |
||
− | :done() |
||
− | |||
− | local result = p.load(teamlink, tournamentType, limit) |
||
− | |||
− | for _,row in ipairs(result) do |
||
− | tr = tbl:tag("tr") |
||
− | tr:tag('td'):wikitext(Game{row['Game']}):done() |
||
− | tr:tag("td"):wikitext(row["Date"]):done() -- Need to format this right still |
||
− | :node(placement.makeNode(row.Place)) |
||
− | :tag("td"):wikitext(row["PrizeMarkup"]):done() |
||
− | tdEvent = tr:tag("td"):wikitext(League{row["League"],"onlyimage"} .. " [[" .. row["EventLink"] .. "|" .. row["Event"]) |
||
− | if row["Phase"] ~= "" then |
||
− | tdEvent:wikitext(" - " .. row["Phase"]) |
||
− | end |
||
− | tdEvent:wikitext("]]"):done() |
||
− | |||
− | teammates = {} |
||
− | teammatenames = mw.text.split(row["RosterNames"],",",true) |
||
− | teammatelinks = mw.text.split(row["RosterLinks"],",",true) |
||
− | roles = mw.text.split(row["Roles"],",",true) |
||
− | |||
− | if teammatelinks[1] ~= "" then |
||
− | for index,teammatelink in ipairs(teammatelinks) do |
||
− | teammates[#teammates+1] = (roles[index] or '') .. " [[" .. teammatelink .. "|" .. teammatenames[index] .. "]]" |
||
− | end |
||
− | end |
||
− | tr:tag("td"):wikitext(table.concat(teammates, " • ")) |
||
− | tr:done() |
||
− | end |
||
− | |||
− | text = tostring(tbl) |
||
− | |||
− | return text |
||
end |
end |
||
+ | function Results:getTypeWhereCondition(args) |
||
− | function p.load(teamlink, tournamentType, limit) |
||
+ | if args.type then return ('T.EventType="%s"'):format(args.type) end |
||
− | local fieldstable = { |
||
− | "TournamentResults.TeamLink=TeamLink", |
||
− | "TournamentResults.Prize_Markup=PrizeMarkup", |
||
− | "TournamentResults.PrizeOther=PrizeOther", |
||
− | "TournamentResults.Prize=Prize", |
||
− | "TournamentResults.PrizeUnit=PrizeUnit", |
||
− | "TournamentResults.Date=Date", |
||
− | "TournamentResults.Place=Place", |
||
− | "TournamentResults.Event=Event", |
||
− | "TournamentResults.Phase=Phase", |
||
− | "CONCAT(TournamentResults._pageName)=EventLink", |
||
− | "TournamentRosters.RosterLinks__full=RosterLinks", |
||
− | "TournamentRosters.Roster=RosterNames", |
||
− | 'TournamentRosters.Roster_Linked=Roster', |
||
− | "TournamentRosters.Roles=Role", |
||
− | "TournamentRosters.Roles_Markup=Roles", |
||
− | --"TournamentResults.LastResult=LastResult", |
||
− | --"TournamentResults.LastOpponent_Markup=LastOpponent", |
||
− | 'InfoboxTournament.Game=Game', |
||
− | "InfoboxTournament.League=League", |
||
− | } |
||
− | |||
− | local cargotables = "TournamentRosters, TournamentResults, InfoboxTournament" |
||
− | local cargojoin = "TournamentResults.RosterPage = TournamentRosters._pageName, TournamentResults._pageName=InfoboxTournament._pageName" |
||
− | local cargofields = table.concat(fieldstable,",") |
||
− | local cargowhere = 'TournamentResults.TeamLink="' .. teamlink .. '" AND TournamentRosters.UniqueLine = TournamentResults.UniqueLine' |
||
− | local cargogroupBy = "TournamentResults.UniqueLine" |
||
− | local cargoorderBy = "TournamentResults.Date desc" |
||
− | |||
− | if tournamentType and tournamentType ~= '' then |
||
− | cargowhere = cargowhere .. ' AND InfoboxTournament.Type = "' .. tournamentType .. '" ' |
||
− | end |
||
− | if not limit then |
||
− | limit = 5000 |
||
− | end |
||
− | |||
− | local cargoquery = { where = cargowhere, join = cargojoin, groupBy = cargogroupBy, orderBy = cargoorderBy, limit=limit } |
||
− | local result = mw.ext.cargo.query(cargotables, cargofields, cargoquery) |
||
− | |||
− | return result |
||
end |
end |
||
Latest revision as of 19:23, 31 August 2021
Documentation for this module may be created at Module:TeamResults/doc
local util_args = require('Module:ArgsUtil')
local util_cargo = require('Module:CargoUtil')
local util_esports = require('Module:EsportsUtil')
local util_html = require('Module:HtmlUtil')
local util_map = require('Module:MapUtil')
local util_table = require('Module:TableUtil')
local util_text = require('Module:TextUtil')
local util_toggle = require('Module:ToggleUtil')
local util_tournament = require('Module:TournamentUtil')
local util_vars = require('Module:VarsUtil')
local i18n = require('Module:i18nUtil')
local m_team = require('Module:Team')
local lang = mw.getLanguage('en')
local Results = require('Module:TeamResultsAbstract'):extends()
function Results:init()
self:super('init', 'Team')
self.limitOverviewpage = 10
self.limitEverything = 500
self.COLUMNS = { 'Game', 'Date', 'PlaceDisplay', 'PrizeDisplay', 'Tournament', 'Roster' }
end
local p = {}
function p.main(frame)
local args = util_args.merge()
return Results():run(args)
end
function Results:getSubject(args)
return args[1] and m_team.teamlinkname(args[1]) or mw.title.getCurrentTitle().baseText
end
function Results:getSubjectWhereCondition(args, subject)
return ('Res.Team="%s"'):format(subject)
end
function Results:getTypeWhereCondition(args)
if args.type then return ('T.EventType="%s"'):format(args.type) end
end
return p