Module:XfD old/AfD and MfD/sandbox: Difference between revisions

Content deleted Content added
Properly match up with current Template:XFD backlog behavior
Refactor
Line 3:
-- and "Old" discussions aren't displayed separately from "Current" ones
function p.rfd(frame)
local month = frame.args.month
local rfd = "Wikipedia:Redirects for discussion"
local logprefix = "Wikipedia:Redirects for discussion/Log/"
-- threshold is 7 days ago
local threshold = os.date("%F",os.time() - (86400*7))
local monthymd = frame.argsrequire("Module:YMD to ISO").month_main
local ymdtoiso = require("Module:YMD to ISO")._main
local lang = mw.getContentLanguage()
-- Find the daily pages
local content = mw.title.new(rfd):getContent()
local dayPattern = "{{" .. logprefix .. "(.-)}}";
local total = 0
local lastOpenTitlelastTitle
for ymdday in content:gmatch("{{" .. logprefix .. "(.-)}}"dayPattern) do
local isodatestamp = ymdtoiso(ymd(day)
if isodatestamp <>= threshold then
-- These dicussions aren't seven days old yet
ifelseif month == "total" or month == lang:formatDate("F Y", isodatestamp) then
local dayContent = mw.title.new(logprefix .. ymd):getContent()
local dayTitle = logprefix .. day;
-- Match only title sections starting with lists or templates
local dayContent = mw.title.new(logprefix .. ymddayTitle):getContent()
for openTitle in dayContent:gmatch("==== ?([^\n]-) ?====%s+[%*%#%{]", "") do
-- Match only title sections starting with lists or templates
total = total + 1
forlocal openTitletitlePattern in= dayContent:gmatch("==== ?([^\n]-) ?====%s+[%*%#%{]", "") do;
lastOpenTitle = openTitle
for title in dayContent:gmatch(titlePattern) do
end
total = total + 1
lastTitle = title
end
end
Line 30 ⟶ 33:
if month == "total" then
if total > 0 then
return "[[" .. rfd .. "#" .. lastOpenTitlelastTitle .. "|" .. total .. "]]"
else
return "[[" .. rfd .. "|0]]"