Module:ScheduleHistoryH2H/Regions

local util_args = require('Module:ArgsUtil') local util_cargo = require('Module:CargoUtil') local util_html = require('Module:HtmlUtil') local util_time = require('Module:TimeUtil') local util_vars = require('Module:VarsUtil') local m_team = require('Module:Team') local Region = require('Module:Region')

local TS = require('Module:ScheduleHistoryH2HAbstract'):extends

TS.COLUMNS = { 'Date', 'Event', 'Round', 'Team 1', 'Team 2', 'Score' }

local h = {} local p = {}

function p.main(frame) local args = util_args.merge return TS(args[1], args[2]):run(args) end

function TS:init(arg1, arg2) self:super('init', arg1, arg2) self.entityLiteral1 = self.entity1:name self.entityLiteral2 = self.entity2:name end

function TS:getEntity(arg) return Region(arg) end

function TS:getTables return { 'MatchSchedule=MS', 'TeamRedirects=TR1', 'Teams=IT1', 'TeamRedirects=TR2', 'Teams=IT2', } end

function TS:getJoin return { 'MS.Team1=TR1.AllName', 'TR1._pageName=IT1._pageName', 'MS.Team2=TR2.AllName', 'TR2._pageName=IT2._pageName', } end

function TS:getFields return { 'MS._pageName=_pageNameMS', 'MS.Team1', 'MS.Team2', 'MS.DateTime_UTC=UTC', 'MS.OverviewPage', 'MS.Winner', 'MS.Tab', 'MS.Round', 'MS.Team1Score [number]', 'MS.Team2Score [number]', 'MS.ShownName', 'IT1.Region=Region1 [region]', 'IT2.Region=Region2 [region]', 'IT1.Region=Entity1', 'IT2.Region=Entity2', } end

function TS:getWhere(args) local tbl = { self:getWhereRegionCondition, util_cargo.whereFromArg('MS.OverviewPage RLIKE "%s"', args.forceinclude), util_cargo.whereFromArg('MS.OverviewPage NOT RLIKE "%s"', args.exclude) }	return util_cargo.concatWhere(tbl) end

function TS:getWhereRegionCondition local tbl = { ('(IT1.Region="%s" AND IT2.Region="%s")'):format(self.entity1:get, self.entity2:get), ('(IT1.Region="%s" AND IT2.Region="%s")'):format(self.entity2:get, self.entity1:get), }	return util_cargo.concatWhereOr(tbl) end

-- process function TS:getEntityMarkup(row, i) return row['Region' .. i]:image .. m_team.rightmediumlinked(row['Team' .. i]) end

-- output function TS:markupTotalEntity1 return self.entity1:name .. '&ensp;' .. self.entity1:image .. '&ensp;' end

function TS:markupTotalEntity2 return '&ensp;' .. self.entity2:image .. '&ensp;' .. self.entity2:name end

return p