Module:Maintenance Category Report

local p = {}

local utilsArg = require("Module:UtilsArg") local utilsLayout = require("Module:UtilsLayout") local utilsPage = require("Module:UtilsPage")

function p.Main(frame) local args = utilsArg.parse(frame:getParent.args, p.Templates["Maintenance Category Report"]) local rows = {} for i, entry in ipairs(args.entries) do		local pageCount = #utilsPage.dpl({			category = entry.cat,			notnamespace = {"Category", args.excludeUserPages and "User" or nil},			redirects = "include",		}) local statusModifier if entry.err and pageCount >= entry.err then statusModifier = "error" elseif entry.warn and pageCount >= entry.warn then statusModifier = "warn" elseif entry.err or entry.warn then statusModifier = "ok" end local pageCountCell = { content = pageCount, class = "zw-maintenance-category-report__page-count" }		if statusModifier then pageCountCell.class = pageCountCell.class .. " zw-maintenance-category-report__page-count--status-"..statusModifier end local categoryLink = string.format("%s", entry.cat, entry.cat) table.insert(rows, {categoryLink, pageCountCell}) end local wikitable = utilsLayout.table({		class = "wikitable zw-maintenance-category-report",		headers = {"Category", "Page Count"},		rows = rows	}) return wikitable end

p.Templates = { ["Maintenance Category Report"] = { format = "block", repeatedGroup = { name = "entries", params = {"cat", "warn", "err"}, },		boilerplate = { separateRequiredParams = false, },		params = { excludeUserPages = { type = "boolean", desc = "If present, pages in the  namespace will not be included in the count" },			cat = { required = true, type = "string", desc = "A maintenance category name, without the  namespace prefix.", },			warn = { type = "number", desc = "A threshold value for the number of pages in the category, beyond which the category is considered to be in a 'warning' state." },			err = { type = "number", desc = "A threshold value for the number of pages in the category, beyond which the category is considered to be in an error state.", },		},		examples = { {				excludeUserPages = "true", cat1= "Pages with script errors", err1 = 1, cat2= "Articles using invalid arguments in template calls", warn2 = 1, cat3= "Pages with reference errors", warn3 = 1, cat4= "Files needing deletion" }		},	}, }

return p