Module:PlayerResultsSolos

local placement = require('Module:Placement') local Team = require('Module:Team').team local League = require('Module:League').league local Role = require('Module:Role').role

local p = {}

function p.playerResultsSolos( frame ) if frame == mw.getCurrentFrame then args = require( 'Module:ProcessArgs').norm else frame = mw.getCurrentFrame end local player = args[1] or mw.title.getCurrentTitle.baseText local fieldstable = { "TournamentResultsSolos.TeamLink=TeamLink", "TournamentResultsSolos.Prize_Markup=PrizeMarkup", "TournamentResultsSolos.Date=Date", "TournamentResultsSolos.Place=Place", "TournamentResultsSolos.Event=Event", "TournamentResultsSolos.Phase=Phase", "CONCAT(TournamentResultsSolos._pageName)=EventLink", "TournamentRostersSolos.RosterLinks__full=RosterLinks", "TournamentRostersSolos.Roster=RosterNames", "TournamentRostersSolos.Roles_Markup=Roles", "Tournaments.League=League", "CONCAT(PlayerRedirects.AllName)=ThisName", }	local cargotables = "TournamentRostersSolos, TournamentResultsSolos, Tournaments, PlayerRedirects" local cargojoin = "TournamentRostersSolos._pageName = TournamentResultsSolos.RosterPage, TournamentResultsSolos._pageName=Tournaments._pageName, TournamentRostersSolos.RosterLinks HOLDS PlayerRedirects.AllName" local cargofields = table.concat(fieldstable,",") local cargowhere ='PlayerRedirects._pageName="' .. player .. '" AND TournamentRostersSolos.UniqueLine = TournamentResultsSolos.UniqueLine' local cargogroupBy = "TournamentResultsSolos.UniqueLine" local cargoorderBy = "TournamentResultsSolos.Date desc" local cargoquery = { where = cargowhere, join = cargojoin, groupBy = cargogroupBy, orderBy = cargoorderBy } cargoquery.limit = p.getLimit(args.show) local result = mw.ext.cargo.query(cargotables, cargofields, cargoquery) local tbl = mw.html.create('table') tbl:addClass("wikitable sortable"):css("font-size","90%") :tag("tr") :tag("th"):css({ background = "#E6E6E6", border = "1px solid black" }):attr("colspan","30") :wikitext(Team{team,"teamname"} .. ' Tournament Results'):done :done :tag("tr") :tag("th"):css("width","60"):wikitext("Date"):done :tag("th"):css("width","60"):wikitext("Place"):done :tag("th"):css("width","250"):wikitext("Event"):done :tag("th"):css("width","250"):wikitext("Team"):done :tag("th"):wikitext("Roster"):done :done for _,row in ipairs(result) do		tr = tbl:tag("tr") tr:tag("td"):css({ ['white-space'] = 'nowrap' }):wikitext(row.Date):done :node(placement.makeNode(row.Place)) tdEvent = tr:tag("td"):wikitext(League{row.League,"onlyimage"} .. " " .. row.Event)		if row["Phase"] ~= "" then			tdEvent:wikitext(" - " .. row.Phase)		end 		tdEvent:wikitext(""):done tr:tag("td"):wikitext(Team{row.TeamLink,"rightshortlinked"}) tr:tag("td"):wikitext(p.getTeammates(row.RosterNames, row.RosterLinks, row.Roles, row.ThisName)) end frame:callParserFunction{name="#vardefine:hasnewresults",args={"yes"}} local text = {} text[#text+1] = p.intro(args.show) text[#text+1] = tostring(tbl) output = table.concat(text,'') return output end

function p.getLimit(show) if show == 'overviewpage' then return 10 elseif show == 'everything' then return 500 end return nil end

function p.getTeammates(namesstr, linksstr, rolesstr, thisname) local teammates = {} local teammatenames = mw.text.split(namesstr,"%s*,%s*") local teammatelinks = mw.text.split(linksstr,"%s*,%s*") local roles = mw.text.split(rolesstr,"%s*;;%s*") for index,teammatelink in ipairs(teammatelinks) do		local thisroles = {} local thisrole = table.concat(thisroles,"") if mw.ustring.lower(teammatelink) == mw.ustring.lower(thisname) then teammates[#teammates+1] = thisrole .. " '''" .. teammatenames[index] .. "'''"		else teammates[#teammates+1] = thisrole .. " " .. teammatenames[index] .. "" end end local output = table.concat(teammates, ", ") return output end

function p.intro(show) if show == 'overviewpage' then return string.format(":This table shows up to the 10 most recent results. For complete results, click here.",mw.title.getCurrentTitle.rootText) end return '' end

function p.intro(show) if notitletext == 'yes' then return nil end return '' end

return p