Module:NUMBEROF/rank: Difference between revisions

Content deleted Content added
 
rank wikipedia sister project only; other sister projects in Module:NUMBEROF/other to split overhead
Line 1:
-- Return a table of statistics to be accessed once per page using mw.loadData.
-- TheFor each sister project, the table ranks each site of form xxx.wikipedia by its number of articles.
 
local functionprojects makeData()= {
'wikipedia',
local statistics = mw.ext.data.get('Wikipedia statistics/datarank.tab') -- https://commons.wikimedia.org/wiki/Data:Wikipedia_statistics/datarank.tab
}
 
local function getData(statistics)
local iSite, iArticles
for i, v in ipairs(statistics.schema.fields) do
Line 18 ⟶ 21:
end
return {
rankByIndex = rankByIndex, -- rankByIndex[1] == 'en.wikipedia'
rankBySite = rankBySite, -- rankBySite['en.wikipedia'] == 1
}
end
 
local function makeData()
-- For example, data to rank each language for sister project wikipedia is at
local statistics = mw.ext.data.get('Wikipedia statistics/datarank.tab') -- https://commons.wikimedia.org/wiki/Data:Wikipedia_statistics/datarankrank/wikipedia.tab
local result = {}
for _, project in ipairs(projects) do
local file = 'Wikipedia statistics/rank/' .. project .. '.tab'
result[project] = getData(mw.ext.data.get(file))
end
return result
end