Module:NUMBEROF/rank: Difference between revisions

Content deleted Content added
 
minor tweak to match a change at meta
 
(2 intermediate revisions by 2 users not shown)
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
result[project] = getData(mw.ext.data.get('Wikipedia statistics/rank/' .. project .. '.tab'))
end
return result
end