Module:Standings
From eSportsAmaze
More actions
Documentation for this module may be created at Module:Standings/doc
local p = {}
function p.main(frame)
local args = frame:getParent().args
local tournament = args.tournament or ""
local stage = args.stage or ""
local group = args.group or ""
local qlimit = tonumber(args.qlimit) or tonumber(frame:callParserFunction('#var', 'qlimit')) or 8
local estart = tonumber(args.estart) or tonumber(frame:callParserFunction('#var', 'estart')) or 13
-- Query Cargo Data
local tables = "StageStandings"
local fields = "team, teamshort, matchesplayed, wwcd, placepts, elimpts, totalpts, lastmatchrank"
local queryArgs = {
where = "tournament = '" .. tournament .. "' AND stage = '" .. stage .. "'",
orderBy = "totalpts DESC, wwcd DESC, placepts DESC, elimpts DESC, lastmatchrank ASC"
}
if group ~= "" then
queryArgs.where = queryArgs.where .. " AND groupname = '" .. group .. "'"
end
local results = mw.ext.cargo.query(tables, fields, queryArgs)
-- Build the Table
local root = mw.html.create('table')
root:addClass('match-card-table standings-table')
:css('width', '100%')
:css('border-collapse', 'collapse')
-- Header Row
local header = root:tag('tr')
header:tag('th'):css('width', '40px'):css('text-align', 'center'):wikitext('#')
header:tag('th'):css('text-align', 'left'):wikitext('Team')
header:tag('th'):css('width', '50px'):css('text-align', 'center'):wikitext('MP')
header:tag('th'):css('width', '50px'):css('text-align', 'center'):wikitext('WWCD')
header:tag('th'):addClass('nomobile'):css('width', '60px'):css('text-align', 'center'):wikitext('Place')
header:tag('th'):css('width', '60px'):css('text-align', 'center'):wikitext('Elims')
header:tag('th'):css('width', '70px'):css('text-align', 'center'):wikitext('Total')
-- Data Rows
for i, row in ipairs(results) do
local rowclass = "qual-mid"
if i <= qlimit then
rowclass = "qual-yes"
elseif i >= estart then
rowclass = "qual-no"
end
local tr = root:tag('tr')
tr:addClass('match-card-row ' .. rowclass)
-- Rank Cell
tr:tag('td'):addClass('rank-cell'):wikitext('')
-- Team Cell
local teamCell = tr:tag('td'):addClass('team-cell')
teamCell:tag('span'):addClass('nomobile'):wikitext('[[' .. row.team .. ']]')
teamCell:tag('span'):addClass('mobile-only'):wikitext('[[' .. row.team .. '|' .. row.teamshort .. ']]')
-- Data Cells
tr:tag('td'):css('text-align', 'center'):wikitext(row.matchesplayed)
tr:tag('td'):css('text-align', 'center'):wikitext(row.wwcd)
tr:tag('td'):addClass('nomobile'):css('text-align', 'center'):wikitext(row.placepts)
tr:tag('td'):css('text-align', 'center'):wikitext(row.elimpts)
tr:tag('td'):addClass('total-cell'):wikitext(row.totalpts)
end
return tostring(root)
end
return p