Module:Archive URL counts/data

.mw-parser-output .documentation,.mw-parser-output .documentation-metadata{border:1px solid var(--border-color-base,#a2a9b1);background-color:#ecfcf4;color:inhe

Module:Archive URL counts/data
-- Return a table of URL statistics to be accessed once per page using mw.loadData.
-- Data is pulled from Commons:Data:Wikipedia statistics/exturls.tab

local function last_update_get (description)
	return description:match ('%a%a%a %d%d? %d%d:%d%d:%d%d UTC %d%d%d%d');		-- extract and return the date substring; we'll prettify it later
end


local function makeData()
	local statistics = mw.ext.data.get('Wikipedia statistics/exturls.tab')
	local data = {}
	
	-- The schema fields dynamically map the column names to their index
	local map = {}
	for i, v in ipairs(statistics.schema.fields) do
		if i > 1 then
			map[v.name] = i - 1  -- skip 'site' column, names are lowercase
		end
	end

	-- Build the fast-lookup table
	-- Since there are 16 data columns (excluding 'site'), we unpack them all
	for _, v in ipairs(statistics.data) do
		data[v[1]] = { 
			v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9],
			v[10], v[11], v[12], v[13], v[14], v[15], v[16], v[17]
		}
	end
	
	return {
		data = data,
		map = map,
		last_update = last_update_get (statistics.description),					-- <statistics.description> holds the date of the table's last update; extract the date
	}
end

return makeData()

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.