Module:RegionMetadata

From Leaguepedia | League of Legends Esports Wiki
Jump to: navigation, search

Documentation for this module may be created at Module:RegionMetadata/doc

local util_args = require('Module:ArgsUtil')
local util_cargo = require('Module:CargoUtil')
local h = {}

local p = {}
function p.main(frame)
	local args = util_args.merge()
	local data = h.getData(args, args.region)
	h.store(data)
end

function h.getData(args, region)
	local ret = {}
	for k, v in pairs(args) do
		if tostring(k):find('^%d%d%d%dstatus$') then
			ret[#ret+1] = h.getCargoStore(k, v, region)
		end
	end
	return ret
end

function h.getCargoStore(k, v, region)
	local ret = {
		_table = 'RegionStatuses',
		Year = h.getYear(k),
		Status = v,
		Region = region,
	}
	return ret
end

function h.getYear(str)
	return str:match('^(%d%d%d%d)')
end

function h.store(data)
	for _, row in ipairs(data) do
		util_cargo.store(row)
	end
end

return p