Module:NUMBEROF: Difference between revisions

Content deleted Content added
rank all sister projects
get active, closed, languages count for each project
Line 49:
 
local function main(frame)
local countWords = { active = true, closed = true, languages = true, }
local args = frame:getParent().args
local action = trimArg(args[1], 1) -- activeusers, admins, articles, edits, files, pages, users, depth
Line 54 ⟶ 55:
action = trimArg(action:sub(9), 1)
end
local wantCount = countWords[action]
local site = trimArg(args[2], 2) -- "af" or "af.wikipedia" or "af.wikiquote" etc., including "total"
local site = trimArg(args[2], not wantCount and 2 or nil)
if not site:find('.', 1, true) then
if wantCount then
-- site is nil or a project like 'wikiquote'
site = site or 'wikipedia'
ifelseif not site:find('.', 1, true) then
local -- site =is trimArg(args[2], 2) --like "af" or "af.wikipedia" or "af.wikiquote" etc., including "total"
site = site .. '.wikipedia'
end
local wantComma = trimArg(args[3]) -- nil for no commas in output; "N" or anything nonblank inserts commas
local result = getIfLocal(site, action)
if not resultwantCount then
local data = mw.loadData('Module:NUMBEROF/datacount')
local mapnrActive = data.mapnrActive[site]
datalocal nrClosed = data.datanrClosed[site]
if nrActive and nrClosed then
result = data[site]
if resultaction == 'active' then
result = getValue(result, action, map)nrActive
elseif action == 'closed' then
result = nrClosed
else
result = nrActive + nrClosed
end
end
else
result = getIfLocal(site, action)
if not result then
local data = mw.loadData('Module:NUMBEROF/data')
local map = data.map
data = data.data
result = data[site]
if result then
result = getValue(result, action, map)
end
end
end