Module:PlayerResultsPage

local p = {}

function p.playerResults( frame ) if frame == mw.getCurrentFrame then args = require( 'Module:ProcessArgs').norm else frame = mw.getCurrentFrame end local player = args[1] or tostring(mw.title.getCurrentTitle)

local placement = mw.loadData('Module:Placementnames') local Team = require('Module:Team').team local League = require('Module:League').league --local Role = require('Module:Role').role local tournamentType = args[2] or '' local limit = args[3] or 5000 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=Roles", --"TournamentResults.LastResult=LastResult", --"TournamentResults.LastOpponent_Markup=LastOpponent", "Tournaments.League=League", 'Tournaments.Game=Game', "CONCAT(PlayerRedirects.AllName)=ThisName", }	local earnings = {} local cargotables = "TournamentRosters, TournamentResults, Tournaments, PlayerRedirects" local cargojoin = 'TournamentRosters._pageName = TournamentResults.RosterPage, TournamentResults._pageName=Tournaments._pageName, TournamentRosters.RosterLinks HOLDS PlayerRedirects.AllName' local cargofields = table.concat(fieldstable,",") local cargowhere = 'PlayerRedirects._pageName="' .. player .. '" AND TournamentRosters.TeamLink = TournamentResults.TeamLink' local cargogroupBy = "TournamentResults.UniqueLine" local cargoorderBy = "TournamentResults.Date desc"

if tournamentType ~= '' then cargowhere = cargowhere .. ' AND Tournaments.Type = "' .. tournamentType .. '" ' end local cargoquery = { where = cargowhere, join = cargojoin, groupBy = cargogroupBy, orderBy = cargoorderBy, limit=limit } 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"} .. ' Recent 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"):css("width","250"):wikitext("Team"):done --:tag("th"):wikitext("Roster"):done :done for _,row in ipairs(result) do		mw.log('result') place = placement[string.lower(row["Place"])] or { bgcolor = "", hiddensort = "", fontcolor = "red", display = "Invalid Placement Name" } tr = tbl:tag("tr") tr:tag('td'):wikitext(frame:expandTemplate{title='Game', args={row['Game']}}):done -- TODO Game Module instead of template tr:tag("td"):css({ ['white-space'] = 'nowrap' }):wikitext(row["Date"]):done -- Need to format this right still :tag("td") :css({ ["background-color"] = "#" .. place["bgcolor"], color = place["fontcolor"], ["text-align"] = "center" }) :wikitext(' ' .. place.hiddensort .. " " .. place.display .. "") :done :tag("td"):wikitext(row["PrizeMarkup"]):done tdEvent = tr:tag("td"):wikitext(League{row["League"],"onlyimage"} .. " " .. row["Event"])		if row["Phase"] ~= "" then			tdEvent:wikitext(" - " .. row["Phase"])		end 		tdEvent:wikitext(""):done --if row["LastOpponent"] == "Group Stage (W/L)" then --	row["LastOpponent"] = "Group Stage" --end --tr:tag("td"):wikitext(' ' .. row["LastResult"] .. ' ' .. row["LastOpponent"]) tr:tag("td"):wikitext(Team{row["TeamLink"],"rightshortlinked"}) if row["Prize"] ~= "" then earnings[row["PrizeUnit"]] = (earnings[row["PrizeUnit"]] or 0) + tonumber(row["Prize"],10) end end local td = tbl:tag("tr") --:tag("th"):attr("colspan","30"):wikitext("Total Prize: ") local earningstable = {} td:wikitext(table.concat(earningstable," &#8226; ")):done text = tostring(tbl) frame:callParserFunction{name="#vardefine:hasnewresults",args={"yes"}} return text end

return p