Module:List tuning sessions
Module documentation
[create]
return {
main = function ( frame )
local args = frame.args
local dep = args.dep
local startYear = 2019
local currentDate = os.date('*t');
local currentMonth = currentDate.month
-- The fiscal year starts in July (07), end of first quarter is start of October
-- Start showing the year at the start of October, the earliest time that
-- the first report of the year can be published.
-- ("Ideally the sessions take place within four weeks of a quarter close,
-- however we are still evaluating the schedule for the remainder of this
-- fiscal year" - LHamilton (WMF) )
-- local currentYear = currentDate.year - ( currentDate.month < 10 and 1 or 0 )
-- local lastQuarter = math.floor( ( ( currentMonth + 2 ) % 12 ) / 3 ) -- 0-indexed
-- Tuning session reports ended in FY21-22 Q3
local currentYear = 2021
local lastQuarter = 2
local result = ""
while startYear <= currentYear do
local quarter = 0
local untilQuarter = startYear == currentYear and lastQuarter or 3
while quarter <= untilQuarter and quarter < 4 do
local ordWord = ( { 'first', 'second', 'third', 'fourth' } )[ quarter + 1 ]
local ordNum = ( { '1st', '2nd', '3rd', '4th' } )[ quarter + 1 ]
local pattern1 = string.format(
'File:Wikimedia Foundation %s quarter %s-%s tuning session - %s.pdf',
ordWord, startYear, startYear + 1, dep
)
local pattern2 = string.format(
'File:Wikimedia Foundation %s Quarter %s-%s Tuning Session - %s.pdf',
ordNum, startYear, startYear + 1, dep
)
local linkText = string.format( '%s-%s, %s quarter', startYear, startYear + 1, ordWord )
if mw.title.new( pattern1 ).fileExists then
result = result .. '\n* [[:' .. pattern1 .. '|' .. linkText .. ']]'
else
result = result .. '\n* [[:' .. pattern2 .. '|' .. linkText .. ']]'
end
quarter = quarter + 1
end
startYear = startYear + 1
end
return result
end
}