Module:UpdateHistoryGlobal

local dataModel = require("Module:Data").model local cargo = require('Module:CargoUtil') local p = {}

function p.mementoListByDate local mementoExtra = mw.loadData("Module:Data/Extra/Memento") local render_mem_icon = require('Module:Render/Memento')._icon local sb = {}

table.insert(sb, '{| class="wikitable sortable frozen-header"') table.insert(sb, '!Date') table.insert(sb, '!Memento') table.insert(sb, '!Rarity') table.insert(sb, '!Source') local rows = {} local inames = {} for iname, memData in pairs(mementoExtra) do   	if memData.glDate then inames[#inames+1] = iname end end local mementos = cargo.query{ tables = {'ConceptCard=CC', 'ConceptCardLoc=CCLoc', 'Pages'}, join = { 'CC.iname = Pages.iname', 'CC.iname = CCLoc.iname', },		fields = { 'Pages._pageName = _pageName', 'CC.iname = iname', 'CC.server = server', 'CC.rare = rare', 'CC.icon = icon', 'CCLoc.name = name', },		where = { 'Pages.type = "Memento"', ('CC.iname IN ("%s")'):format(table.concat(inames, '","')), 'CC.server = "gl"', 'CCLoc.lang = "english"', },           	    }    for _, mem in ipairs(mementos) do		local memData = mementoExtra[mem.iname] if mem.rare then local tempOutput = {} table.insert(tempOutput, '|-') table.insert(tempOutput, '| '..memData.glDate) table.insert(tempOutput, '|'..render_mem_icon({data=mem, size='small'})) table.insert(tempOutput, '|'..(tonumber(mem.rare or 0)+1)) table.insert(tempOutput, '|'..memData.source) table.insert(rows, {               date = memData.glDate,                output = table.concat(tempOutput, "\n")            }) end end

table.sort(rows, function(a, b) return a.date > b.date end) for i, row in ipairs(rows) do       table.insert(sb, row.output) end table.insert(sb, "|}")

return table.concat(sb, "\n") end

function p.gearListByDate local gearExtra = mw.loadData("Module:Data/Extra/Gear") local render_gear_icon = require('Module:Render/Gear')._icon local sb = {}

table.insert(sb, '{| class="wikitable sortable frozen-header"') table.insert(sb, '!Date') table.insert(sb, '!Gear') table.insert(sb, '!Rarity') table.insert(sb, '!Source') local gearRows = {} for iname, gearData in pairs(gearExtra) do       if gearData['glDate'] then local gear = dataModel.query("Artifact", "_pageName,rini,icon", {where = 'iname="'..iname..'" and server = "gl"'})[1] or {} if gear.rini then local tempOutput = {} table.insert(tempOutput, '|-') table.insert(tempOutput, '| '..gearData['glDate']) table.insert(tempOutput, '|'..render_gear_icon({iname, data=gear, size='small'})) table.insert(tempOutput, '|'..(gear.rini+1)) table.insert(tempOutput, '|'..gearData['source']) table.insert(gearRows, {                   date = gearData['glDate'],                    output = table.concat(tempOutput, "\n")                }) end end end

table.sort(gearRows, function(a, b) return a.date > b.date end) for i, row in ipairs(gearRows) do       table.insert(sb, row.output) end table.insert(sb, "|}")

return table.concat(sb, "\n") end

function p.unitListByDate local unitExtra = mw.loadData("Module:Data/Extra/Unit") local render_unit_icon = require('Module:Render/Unit')._icon local sb = {}

table.insert(sb, '{| class="wikitable sortable frozen-header"') table.insert(sb, '!Date') table.insert(sb, '!Unit') table.insert(sb, '!Rarity') table.insert(sb, '!Source') local unitRows = {} for iname, unitData in pairs(unitExtra) do       if unitData['glDate'] then local unit = dataModel.query("Unit", "_pageName,rare,img", {where = 'iname="'..iname..'" and server = "gl"'})[1] or {} if unit.rare then local tempOutput = {} table.insert(tempOutput, '|-') table.insert(tempOutput, '| '..unitData['glDate']) table.insert(tempOutput, '|'..render_unit_icon({iname, data=unit, size='small'})) table.insert(tempOutput, '|'..(unit.rare+1)) table.insert(tempOutput, '|'..unitData['source']) table.insert(unitRows, {                   date = unitData['glDate'],                    output = table.concat(tempOutput, "\n")                }) end end end

table.sort(unitRows, function(a, b) return a.date > b.date end) for i, row in ipairs(unitRows) do       table.insert(sb, row.output) end table.insert(sb, "|}")

return table.concat(sb, "\n") end

return p