Documentation for this module may be created at Module:Franchise/Cache/doc
local utilsCargo = require("Module:UtilsCargo") local utilsString = require("Module:UtilsString") local utilsTable = require("Module:UtilsTable") local gameFields = "name, logo, caption, gameCode, releaseOrder, releaseDate, publisher, developer" local bookFields = "name, image, caption, gameCode, releaseOrder, releaseDate, publisher, developer" local tvFields = "name, image, caption, gameCode, releaseOrder, releaseDate, publisher, developer" local nonFictionFields = "name, image, caption, gameCode, releaseOrder, releaseDate, publisher, developer" local groupFields= "name, image, caption, gameCode, releaseOrder, releaseDate, publisher, developer" local games = utilsCargo.query("Games", gameFields, { sortBy = "releaseOrder", limit = 200 }) local books = utilsCargo.query("Books", bookFields, { sortBy = "releaseOrder" }) local tvShows = utilsCargo.query("TelevisionShows", tvFields, { sortBy = "releaseOrder" }) local nonfiction = utilsCargo.query("Nonfiction", nonFictionFields, { sortBy = "releaseDate" }) local groups = utilsCargo.query("GameGroups", groupFields, { sortBy = "releaseDate" }) -- Cargo isn't sorting properly for some reason groups = utilsTable.sortBy(groups, "releaseDate") nonfiction = utilsTable.sortBy(nonfiction, "releaseDate") local codes = {} local gameCodes = {} local titlesByCode = {} local remakes = {} for _, game in ipairs(games) do codes[tonumber(game.releaseOrder)] = game.gameCode gameCodes[tonumber(game.releaseOrder)] = game.gameCode titlesByCode[string.lower(game.gameCode)] = game if game.remakeOf then for i, remadeGame in ipairs(utilsString.split(game.remakeOf)) do remadeGame = string.lower(remadeGame) remakes[remadeGame] = utilsTable.concat(remakes[remadeGame], game.gameCode) end end end gameCodes = utilsTable.compact(gameCodes) for _, book in ipairs(books) do if utilsString.notEmpty(book.gameCode) then -- workaround for Cargo bug inserting duplicate rows (but without code) codes[tonumber(book.releaseOrder)] = book.gameCode titlesByCode[string.lower(book.gameCode)] = book end end for _, tvShow in ipairs(tvShows) do codes[tonumber(tvShow.releaseOrder)] = tvShow.gameCode titlesByCode[string.lower(tvShow.gameCode)] = tvShow end for _, book in ipairs(nonfiction) do titlesByCode[string.lower(book.gameCode)] = book end for _, group in ipairs(groups) do titlesByCode[string.lower(group.gameCode)] = group end codes.reference = "[[Data:Franchise]]" gameCodes.reference = "[[Data:Franchise]]" return { enum = codes, enumGames = gameCodes, games = games, titlesByCode = titlesByCode, remakes = remakes, nonfiction = nonfiction, groups = groups, }