Module:NUMBEROF/other
Appearance
From Wikipedia, the free encyclopedia
You might want to create a documentation page for this Scribunto module.
Editors can experiment in this module's sandbox (create | mirror) and testcases (create) pages.
Add categories to the /doc subpage. Subpages of this module.
Editors can experiment in this module's sandbox (create | mirror) and testcases (create) pages.
Add categories to the /doc subpage. Subpages of this module.
-- Return a table of statistics to be accessed once per page using mw.loadData. -- For each sister project, the table ranks each site by its number of articles. localprojects={ 'wikibooks', 'wikinews', 'wikiquote', 'wikisource', 'wikiversity', 'wikivoyage', 'wiktionary', } localfunctiongetData(statistics) localiSite,iArticles fori,vinipairs(statistics.schema.fields)do ifv.name=='site'then iSite=i elseifv.name=='articles'then iArticles=i end end localrankBySite,rankByIndex={},{} for_,vinipairs(statistics.data)do rankBySite[v[iSite]]=v[iArticles]-- rank of site from number of articles rankByIndex[v[iArticles]]=v[iSite]-- inverse end return{ rankByIndex=rankByIndex,-- rankByIndex[1] == 'en' rankBySite=rankBySite,-- rankBySite['en'] == 1 } end localfunctionmakeData() -- For example, data to rank each language for sister project wikipedia is at -- https://commons.wikimedia.org/wiki/Data:Wikipedia_statistics/rank/wikipedia.tab localresult={} for_,projectinipairs(projects)do result[project]=getData(mw.ext.data.get('Wikipedia statistics/rank/'..project..'.tab')) end returnresult end returnmakeData()