Module:Transcript/Reports

local p = {}

local DataTable = require("Module:Data Table") local TransclusionArguments = require("Module:Transclusion Arguments") local utilsCargo = require("Module:UtilsCargo") local utilsMarkup = require("Module:UtilsMarkup") local utilsTable = require("Module:UtilsTable")

function p.Copies(frame) local copyTransclusions = TransclusionArguments.fetchTransclusions({		template = "Template:Transcript Copy",		parameters = {"fromPage", "storedAs"},	}) local columnHeaders = {"Page [Rowspan]", "Transcript", "Source Page [Description]"} local rows = {} for i, copy in ipairs(copyTransclusions) do		local copyPage = copy._pageName local sourcePage = copy.arguments.fromPage.value local storedAs = copy.arguments.storedAs.value table.insert(rows, {			""..copyPage.."",			" ",			""..sourcePage..""		}) end local dataTable = DataTable.printTable(rows, {		columns = columnHeaders,	}) return dataTable end

function p.StoredTranscripts(frame) -- Associate transcript names to the pages that reference them local transcriptCopies = TransclusionArguments.fetchTransclusions({		template = "Template:Transcript Copy",		parameters = {"fromPage", "storedAs"},	}) transcriptCopies = utilsTable.groupBy(transcriptCopies, function(copy)		return copy.arguments.fromPage.value	end) transcriptCopies = utilsTable.mapValues(transcriptCopies, utilsTable._groupBy(function(copy) return copy.arguments.storedAs.value end)) transcriptCopies = utilsTable.mapValues(transcriptCopies, utilsTable._mapValues(utilsTable._map("_pageName"))) local storedTranscripts = utilsCargo.query("Transcripts", "_pageName, name") local columns = {"Storing Page [Rowspan]", "Transcript Name", "Referencing Pages [Description]"} local rows = {} for i, transcript in ipairs(storedTranscripts) do		local transcriptPage = transcript._pageName local transcriptName = transcript.name local copyPages = transcriptCopies[transcriptPage] and transcriptCopies[transcriptPage][transcriptName] or {} copyPages = utilsTable.map(copyPages, utilsMarkup.link) copyPages = utilsMarkup.bulletList(copyPages) table.insert(rows, {			""..transcriptPage.."",			" ",			copyPages,		}) end local dataTable = DataTable.printTable(rows, {		columns = columns,	}) return dataTable end

return p