Module:Standings
From eSportsAmaze
More actions
Documentation for this module may be created at Module:Standings/doc
local p = {}
local cargo = mw.ext.cargo
function p.main(frame)
local args = frame:getParent().args
local tournament = args.tournament or ""
local stage = args.stage or ""
local qlimit = tonumber(args.qlimit) or 8
local estart = tonumber(args.estart) or 13
-- Query
local tables = "StageStandings"
local fields = "team, teamshort, matchesplayed, wwcd, placepts, elimpts, totalpts, groupname"
local queryArgs = {
where = "tournament = '" .. tournament .. "' AND stage = '" .. stage .. "'",
orderBy = "totalpts DESC, wwcd DESC, placepts DESC, elimpts DESC"
}
local results = cargo.query(tables, fields, queryArgs)
-- Build Table
local root = mw.html.create('table')
root:addClass('match-card-table standings-table')
:css('width', '100%')
:css('border-collapse', 'collapse')
-- Headers
local header = root:tag('tr')
header:tag('th'):wikitext('#')
header:tag('th'):wikitext('Team')
header:tag('th'):wikitext('MP')
header:tag('th'):wikitext('WWCD')
header:tag('th'):addClass('nomobile'):wikitext('Place')
header:tag('th'):wikitext('Elims')
header:tag('th'):wikitext('Total')
-- 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)
tr:attr('data-value', row.groupname) -- Crucial for your JS Filter!
-- Rank
tr:tag('td'):addClass('rank-cell')
-- Team
local teamTD = tr:tag('td'):addClass('team-cell')
teamTD:wikitext('[[' .. row.team .. ']]')
-- Stats
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