Module:TeamMembersCurrent

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_math = require("Module:MathUtil") local util_news = require("Module:NewsUtil") local util_source = require("Module:SourceUtil") local util_table = require("Module:TableUtil") local util_text = require("Module:TextUtil") local util_time = require("Module:TimeUtil") local util_timedelta = require("Module:TimedeltaUtil") local util_vars = require("Module:VarsUtil") local i18n = require('Module:i18nUtil') local lang = mw.getLanguage('en')

local m_team = require('Module:Team') local m_region = require('Module:Region')

local TMC = require('Module:NewsCurrentStatusAbstract'):extends

local COLUMNS = { 'PlayerDisplay', 'NameDisplay', 'RoleDisplay', 'DateJoinDisplay' }

local h = {}

local p = {} function p.main(frame) local args = util_args.merge h.castArgs(args) i18n.init('TeamMembersCurrent') return TMC:init(args.team) end

function h.castArgs(args) args.team = args.team and m_team.teamlinkname(args.team) end

function TMC:getTables local ret = { 'TeamRedirects=TR', 'RosterChanges=RC', 'NewsItems=News', 'PlayerRedirects=PR', 'Players=P' }	return ret end

function TMC:getJoin local ret = { 'TR.AllName=RC.Team', 'RC.NewsID=News.NewsID', 'RC.Player=PR.AllName', 'PR._pageName=P._pageName', }	return ret end

function TMC:getWhere(team) local where = { ('TR._pageName="%s"'):format(team) }	return util_cargo.concatWhere(where) end

function TMC:getFields local origFields = self:super('getFields') local newFields = { 'COALESCE(P.Nationality__FULL,P.Country)=Country', 'P.Name', }	return util_table.mergeArrays(origFields, newFields) end

function TMC:processOneChangeRow(row) row.Subject = row.Player row.NameDisplay = row.Name row.PlayerDisplay = util_esports.playerLinked(row.Player) row.RoleDisplay = row.Role:names{len='role'} row.DateJoinDisplay = row.Date_Display or lang:formatDate('Y-m-d', row.Date_Sort) row.Priority = row.Role:sortnumber end

function TMC:doWeAddSubjectToOutput(status) return self:super('doWeAddSubjectToOutput', status) and status.Role:hasIngame end

function TMC:makeOutput(listOfSubjects, listOfChanges) util_vars.log(listOfSubjects[1]) local output = mw.html.create local tbl = output:tag('table') :addClass('wikitable') util_html.printHeaderFromI18n(tbl, COLUMNS) util_html.printRowsByList(tbl, listOfSubjects, COLUMNS) return output end

return p