Documentation for this module may be created at Module:Infobox/Widget/Upcoming matches/doc
local cargo = mw.ext.cargo
local stringifyDate = require('Module:Functions').stringifyDate
local p = {}
function p.person()
local currentDate = os.date('%Y-%m-%d')
local tables = 'AllMatches, Participants'
local fields = 'AllMatches._pageName=_pageName, AllMatches.p1=p1, AllMatches.p2=p2, AllMatches.date=date, AllMatches.bestof=bestof'
local playerPage = mw.title.getCurrentTitle().text
local cargoArgs = {
join = 'AllMatches._pageName=Participants._pageName',
where = '(Participants.players HOLDS "' .. playerPage .. '" OR Participants.coaches HOLDS "' .. playerPage .. '" OR Participants.analysts HOLDS "' .. playerPage .. '" OR Participants.managers HOLDS "' .. playerPage .. '") AND (AllMatches.date is NOT NULL AND AllMatches.date > "' .. currentDate .. '") AND (AllMatches.winner IS NULL OR AllMatches.winner = 0) AND ((AllMatches.p1 = Participants.team OR AllMatches.p2 = Participants.team) OR (AllMatches.p1 = "' .. playerPage .. '" OR AllMatches.p2 = "' .. playerPage .. '"))'
}
local results = cargo.query(tables, fields, cargoArgs)
if #results > 0 then
local container = mw.html.create('div'):attr('style', 'padding: 10px;')
for i = 1, #results do
local result = results[i]
local game = mw.text.split(result._pageName, '/')[1] .. '/'
local team1 = mw.html.create('div'):addClass('w-100'):css('text-align', 'end'):wikitext('[[' .. result.p1 .. '|' .. string.gsub(result.p1,game,'') .. ']]')
local team2 = mw.html.create('div'):addClass('w-100'):wikitext('[[' .. result.p2 .. '|' .. string.gsub(result.p2,game,'') .. ']]', '')
local firstRow = mw.html.create('div'):attr('style', 'display: flex; gap: 0.5rem;'):node(team1):node(mw.html.create('div'):wikitext('vs')):node(team2)
local tournament = mw.html.create('div'):addClass('w-100 tc'):wikitext('[[' .. result._pageName .. ']]')
local date = mw.html.create('div'):addClass('w-100'):wikitext(stringifyDate(result.date))
local secondRow = mw.html.create('div'):attr('style', 'display: flex; gap: 0.5rem;'):node(tournament):node(mw.html.create('abbr'):attr('title', 'Best of ' .. result.bestof):wikitext('Bo' .. result.bestof)):node(date)
local match = mw.html.create('div'):attr('style', 'margin-bototm: 15px; border: 1px solid #000; padding: 5px;'):node(firstRow):node(secondRow)
container:node(match)
end
return container
else
return nil
end
return nil
end
return p