Module:Franchise/Cache

local utilsCargo = require("Module:UtilsCargo") local utilsString = require("Module:UtilsString") local utilsTable = require("Module:UtilsTable")

local commonFields = {"id", "code", "shortName", "link", "display", "firstRelease", "canonicity", "type"} local gameFields = utilsTable.concat(commonFields, {"graphics", "family", "remakeOf", "supersededBy"}) local comicFields = utilsTable.concat(commonFields, {"phraseLink", "authors", "basedOn"})

local games = utilsCargo.query("Games2", table.concat(gameFields, ",")) local comics = utilsCargo.query("Comics", table.concat(comicFields, ","))

local codes = {} local titlesByCode = {} local remakes = {}

for _, game in ipairs(games) do	codes[tonumber(game.id)] = game.code titlesByCode[game.code] = game if utilsString.notEmpty(game.remakeOf) then remakes[game.remakeOf] = utilsTable.concat(remakes[game.remakeOf], game.code) end end for _, comic in ipairs(comics) do	if utilsString.notEmpty(comic.code) then -- workaround for Cargo bug inserting duplicate rows (but without code) codes[tonumber(comic.id)] = comic.code titlesByCode[comic.code] = comic end end codes.reference = "Data:Franchise"

return { enum = codes, titlesByCode = titlesByCode, remakes = remakes, }