Module:Team appearances list: Difference between revisions

Content deleted Content added
Automate greying out of absences
Competition records
Line 12:
local hlist = require('Module:List').horizontal
local valueUnion = require('Module:Set').valueUnion
 
local COMPETITIONS = {
["Mediterranean Games"] = {
["years"] = {1951, 1955, 1959, 1963, 1967, 1971, 1975, 1979, 1983, 1987,
1991, 1993, 1997, 2001, 2005, 2009, 2013, 2017}
},
["Pan American Games"] = {
["years"] = {1951, 1955, 1959, 1963, 1967, 1971, 1975, 1979, 1983, 1987,
1991, 1995, 1999, 2003, 2007, 2011, 2015, 2019}
},}
 
function p.main(frame)
Line 19 ⟶ 29:
function p._main(args)
local begin_year = args.begin_year or 0
local end_year = args.end_year or 0
 
local appearances = {}
local absences = {}
Line 26 ⟶ 39:
end
 
local function processYear(y)
for i = args.begin_year, (args.end_year or os.date('%Y')+args.interval),
y = tostring(y)
args.interval do
if absences[tostring(i)y] then
table.insert(appearances, absences[tostring(i)y])
absences[tostring(i)y] = nil
else
table.insert(appearances, mw.ustring.format(
'[[%s at the %s %s|%s]]', args.team, iy, args.competition, iy))
end
end
 
if COMPETITIONS[args.competition] then
for _, y in pairs(COMPETITIONS[args.competition].years) do
if y > begin_year and y < end_year then
processYear(y)
end
end
else
for iy = args.begin_year, (args.end_year or os.date('%Y')+args.interval),
args.interval do
processYear(y)
end
end