Module:NUMBEROF: Difference between revisions

Content deleted Content added
in a parameter, allow "numberofX" as an alias for "X"; accept site en2 to get cached data for en rather than live values (only makes a difference at enwiki)
implement DEPTH parameter for Wikipedias that use it
Line 10:
end
return mw.ustring.lower(arg)
end
 
local function getValue(stats, action, map)
if action == 'depth' then
-- https://meta.wikimedia.org/wiki/Wikipedia_article_depth
-- This gives silly results if, for example, the number of articles is small.
if stats.pages == 0 or stats.articles == 0 then
return 0
end
return math.floor((stats.edits/stats.pages) * ((stats.pages - stats.articles)/stats.articles)^2)
end
if map then
action = map[action]
end
return stats[action]
end
 
Line 21 ⟶ 36:
action = 'activeUsers'
end
return getValue(mw.site.stats[, action])
end
end
Line 48 ⟶ 63:
result = data[site]
if result then
result = getValue(result[map[, action]], map)
end
end