Module:Exclusive/data

-- create data cache from cargo -- The cached query version is not much faster then query directly, but its running speed varies in a much smaller range, avoid accidental timeout. local cargo = mw.ext.cargo local cache = require 'mw.ext.LuaCache'

local info = cache.get('exclusive-database') if info then return info end

local result = mw.ext.cargo.query('Exclusive', 'pagename, desktop, console, oldgen, mobile, 3ds, japanese', {	orderBy = "cached DESC",	groupBy = "pagenamemd5", -- group by is case insensitive, so use group by pagenamemd5 instead of group by pagename.	limit = 5000, -- may be not enough in future. }) info = {} for _, row in ipairs(result) do	-- all are strings local str = ((row['desktop'] ~= ) and 'd' or ) .. ((row['console'] ~= ) and 'c' or ) .. ((row['oldgen'] ~= )  and 'o' or ) .. ((row['mobile'] ~= )  and 'm' or ) .. ((row['3ds'] ~= )     and '3' or ) .. ((row['japanese'] ~= ) and 'j' or ) if str ~= 'dcom3' and str ~= 'dcom3j' and str ~= '' then info[row['pagename']] = str end end -- cache to luacache for 6hrs. cache.set('exclusive-database', info, 3600*6) return info