-- This module is a replacement for the RfX report bot.
local rfx = require('Module:Rfx/sandbox')local colours = mw.loadData('Module:RFX report/colour/sandbox')
local p =
local function getTableLength(tbl) local length = 0 for _ in pairs(tbl) do length = length + 1 end return lengthend
local function getRfxes -- Get the title object for . local noError, rfa = pcall(mw.title.new, 'Wikipedia:Requests for adminship') if not noError or (noError and not rfa) then return nil end local rfaText = rfa:getContent if not rfaText then return nil end -- Return a table with a list of pages transcluded from --, minus the exceptions -- which are always transcluded there. local t = local exceptions = for rfxPage, rfxSubpage in mw.ustring.gmatch(rfaText, '') do local isException = false for _, v in ipairs(exceptions) do if rfxSubpage
local function makeRow(rfxObject) if not (type(rfxObject)
local percentStr = mw.ustring.format('%d', percent) if percent
0 and opposes
0 then percentStr = 'N/A' elseif percent
local votes if supports and opposes and neutrals and percent then votes = mw.ustring.format([==[ | class="rfx-report-number" | [[%s#Support|%d]]| class="rfx-report-number" | %d| class="rfx-report-number" | %d| class="rfx-report-number rfx-report-percent" style="background: #%s;" | %s]
'Pending closure' then status = 'Pending closure...' end status = '\n|' .. status else status = '\n| class="rfx-report-error" | Error getting status' end local endTime = rfxObject.endTime local secondsLeft = rfxObject:getSecondsLeft local timeLeft = rfxObject:getTimeLeft local time if endTime and timeLeft then time = mw.ustring.format('\n| %s\n| %s', endTime, timeLeft) else time = '\n| colspan="2" class="rfx-report-error" | Error parsing end time' end local dupes = rfxObject:dupesExist if dupes then dupes = '
yes' elseif dupes'pending closure' then pending_class = 'class="rfx-report-pending"' end return mw.ustring.format('\n|-%s\n| %s%s%s%s\n| class="rfx-report-dupes" | %s%s', pending_class, page, user, votes, status, time, dupes, report)end
local function makeHeading(rfxType) local frame = mw.getCurrentFrame local rfxCaps if rfxType
'rfb' then rfxCaps = 'RfB' else return nil end return mw.ustring.format('\n|-\n! scope="col" | %s candidate !! scope="col" | S !! scope="col" | O !! scope="col" | N !! scope="col" | S %% !! scope="col" | Status !! scope="col" | Ending (UTC) !! scope="col" | Time left !! scope="col" | Dups? !! scope="col" | Report', rfxCaps)end
local function getRfasRfbsSeparate local rfxes = getRfxes if not rfxes then return nil end -- Get RfX objects and separate RfAs and RfBs. local rfas = local rfbs = for i, rfxPage in ipairs(rfxes) do local rfxObject = rfx.new(rfxPage) if rfxObject then if rfxObject.type
'rfb' then table.insert(rfbs, rfxObject) end end end return rfas, rfbsend
local function makeReportRows local rfas, rfbs = getRfasRfbsSeparate
local ret = if #rfas > 0 then table.insert(ret, makeHeading('rfa')) for i, rfaObject in ipairs(rfas) do table.insert(ret, makeRow(rfaObject)) end end if #rfbs > 0 then table.insert(ret, makeHeading('rfb')) for i, rfbObject in ipairs(rfbs) do table.insert(ret, makeRow(rfbObject)) end end return table.concat(ret)end
[%s update]', purgeLink) local rows = makeReportRows or if rowsthen clear = nil end local style = if float or clear then style = string.format('style="%s%s"', clear and ('clear: ' .. clear .. ';') or , float and ('float: ' .. float .. ';') or ) end
return mw.getCurrentFrame:extensionTag .. mw.ustring.format('\n
-\n |
function p.countRfas local rfas, rfbs = getRfasRfbsSeparate return getTableLength(rfas)end
function p.main(frame) -- Process the arguments. local args if frame
return p