require('Module:Module wikitext')._addText(); local convert = require('মডিউল:সংখ্যা রূপান্তরকারী').convert local rfx = require('Module:Rfx') local colours = mw.loadData('Module:RFX report/colour')  local p = {}  -- Function to extract RfA page titles from the user subpage local function getRfAPagesFromSubpage(subpageTitle)     local subpage = mw.title.new(subpageTitle)     if not subpage then         return {}     end      local content = subpage:getContent()     if not content then         return {}     end      -- Pattern to match links like উইকিপিডিয়া:প্রশাসক হওয়ার আবেদন/username     local rfaPages = {}     for link in string.gmatch(content, "%[%[উইকিপিডিয়া:প্রশাসক হওয়ার আবেদন/([%w%p]+)%]%]") do         table.insert(rfaPages, "উইকিপিডিয়া:প্রশাসক হওয়ার আবেদন/" .. link)     end      return rfaPages end  -- Function to get all ended requests from provided page lists local function getEndedRfxes(rfxPages)     local endedRfxes = {}      -- Process the provided RfX pages     for _, rfxPage in ipairs(rfxPages) do         local rfxObject = rfx.new(rfxPage)         if rfxObject and rfxObject:getStatus() == 'ended' then             table.insert(endedRfxes, rfxObject)         end     end      -- Sort by end time, most recent first     table.sort(endedRfxes, function(a, b)         return a.endTime > b.endTime     end)      return endedRfxes end  -- Function to create rows for the ended RfX requests local function makeRow(rfxObject)     local page = rfxObject:getTitleObject().prefixedText     local user = rfxObject.user or rfxObject:getTitleObject().subpageText     local supports = convert('bn', tostring(rfxObject.supports))     local opposes = convert('bn', tostring(rfxObject.opposes))     local neutrals = convert('bn', tostring(rfxObject.neutrals))     local percent = convert('bn', tostring(rfxObject.percent))     local colour = colours[rfxObject.type][percent] or ''      local percentStr = percent or 0     if supports == '০' and opposes == '০' and neutrals == '০' then         percentStr = 'N/A'     end      local endTime = mw.getContentLanguage():formatDate('d M Y, h:m', rfxObject.endTime, true)      return string.format(         '\n|-\n| %s || %s || %s%% || %s',         page, user, supports .. ' সমর্থন', percentStr, endTime     ) end  -- Function to create the table for recent ended requests local function makeEndedReport(args)     -- Get the RfA pages from the subpage User:R1F4T/খেলাঘর     local rfaPages = getRfAPagesFromSubpage('User:R1F4T/খেলাঘর')      -- Filter the ended requests     local endedRfxes = getEndedRfxes(rfaPages)     if not endedRfxes or #endedRfxes == 0 then         return "No recent ended requests."     end      local rows = {}     local limit = tonumber(args.limit) or 5  -- Default to showing 5 recent requests     for i = 1, math.min(limit, #endedRfxes) do         local rfxObject = endedRfxes[i]         table.insert(rows, makeRow(rfxObject))     end      local header = '\n|+ সাম্প্রতিক সমাপ্ত অনুরোধসমূহ\n|- ! প্রার্থী !! সমর্থন !! সমর্থনের শতকরা হার !! শেষ সময়'     local body = table.concat(rows)      return string.format('\n{| class="wikitable"%s\n|-\n%s\n|}', header, body) end  -- Main function that processes the frame arguments and generates the table function p.main(frame)     local args = frame:getParent().args     return makeEndedReport(args) end  return p