跳转到内容

模組:NUMBEROF/data

被永久保护的模块
维基百科,自由的百科全书

这是本页的一个历史版本,由A2569875留言 | 贡献2020年5月18日 (一) 03:23 建立内容为“-- Return a table of statistics to be accessed once per page using mw.loadData. -- The table contains counts of edits, pages and more for each proje…”的新页面)编辑。这可能和当前版本存在着巨大的差异。

(差异) ←上一修订 | 最后版本 (差异) | 下一修订→ (差异)
-- Return a table of statistics to be accessed once per page using mw.loadData.
-- The table contains counts of edits, pages and more for each project.

local function makeData()
	local statistics = mw.ext.data.get('Wikipedia_statistics/data.tab') -- https://commons.wikimedia.org/wiki/Data:Wikipedia_statistics/data.tab
	local data = {}
	for _, v in ipairs(statistics.data) do
		-- Assume "site" is first entry of 8.
		data[v[1]] = { v[2], v[3], v[4], v[5], v[6], v[7], v[8] }
	end
	local map = {}
	for i, v in ipairs(statistics.schema.fields) do
		-- Assume "site" is first entry and skip it.
		if i > 1 then
			map[v.name] = i - 1  -- name is lowercase
		end
	end
	return {
		data = data,
		map = map,
	}
end

return makeData()