Module:MaintenanceDashboard: Difference between revisions
Adjust thresholds: CRTs Missing Type red/green, Stubs/Images amber/green, No Series as info (via update-page on MediaWiki MCP Server) |
Add Documents cards, fix AV stubs to yellow/green, add missing brand pages check (via update-page on MediaWiki MCP Server) |
||
| Line 47: | Line 47: | ||
return '{{Maintenance status card|label=' .. label .. '|count=' .. count .. '|status=' .. status .. linkAttr .. '}}' | return '{{Maintenance status card|label=' .. label .. '|count=' .. count .. '|status=' .. status .. linkAttr .. '}}' | ||
end | |||
-- Count missing brand pages (brands used but no wiki page exists) | |||
local function countMissingBrandPages(frame) | |||
local missingCount = 0 | |||
local checkedBrands = {} | |||
-- Get all brands from CRT models | |||
local crtBrandQuery = frame:preprocess('{{#ask:[[Category:CRT models]][[Has brand::+]]|?Has brand|format=broadtable|headers=hide|link=none|mainlabel=-|limit=500|searchlabel=}}') | |||
if crtBrandQuery then | |||
for cell in crtBrandQuery:gmatch('<td[^>]*>(.-)</td>') do | |||
local brand = trim(cell:gsub('<[^>]+>', '')) | |||
if brand and brand ~= '' and not checkedBrands[brand] then | |||
checkedBrands[brand] = true | |||
local title = mw.title.new(brand) | |||
if title and not title.exists then | |||
missingCount = missingCount + 1 | |||
end | |||
end | |||
end | |||
end | |||
-- Get all brands from AV devices | |||
local avBrandQuery = frame:preprocess('{{#ask:[[Category:AV devices]][[Has brand::+]]|?Has brand|format=broadtable|headers=hide|link=none|mainlabel=-|limit=500|searchlabel=}}') | |||
if avBrandQuery then | |||
for cell in avBrandQuery:gmatch('<td[^>]*>(.-)</td>') do | |||
local brand = trim(cell:gsub('<[^>]+>', '')) | |||
if brand and brand ~= '' and not checkedBrands[brand] then | |||
checkedBrands[brand] = true | |||
local title = mw.title.new(brand) | |||
if title and not title.exists then | |||
missingCount = missingCount + 1 | |||
end | |||
end | |||
end | |||
end | |||
return missingCount | |||
end | end | ||
| Line 201: | Line 239: | ||
local crtNoSeries = getCount(frame, '[[Category:CRTs without series]]') | local crtNoSeries = getCount(frame, '[[Category:CRTs without series]]') | ||
local avStubs = getCount(frame, '[[Category:AV device stubs]]') | local avStubs = getCount(frame, '[[Category:AV device stubs]]') | ||
local docsMissingContent = getCount(frame, '[[Category:Documents missing content]]') | |||
local docsOrphaned = getCount(frame, '[[Category:Orphaned documents]]') | |||
local missingBrandPages = countMissingBrandPages(frame) | |||
local cards = {} | local cards = {} | ||
-- Stubs and missing images: | -- Missing brand pages: red/green (any = red) | ||
table.insert(cards, statusCard('Missing Brand Pages', missingBrandPages, 'Special:WantedPages', 1, 1)) | |||
-- Missing type: red/green (any missing = red) | |||
table.insert(cards, statusCard('CRTs Missing Type', crtNoType, 'Category:CRTs missing type', 1, 1)) | |||
-- Stubs and missing images: yellow/green (warning at 1, no red) | |||
table.insert(cards, statusCard('CRT Stubs', crtStubs, 'Category:CRT stubs', 1, 99999)) | table.insert(cards, statusCard('CRT Stubs', crtStubs, 'Category:CRT stubs', 1, 99999)) | ||
table.insert(cards, statusCard('CRTs Need Images', crtNoImage, 'Category:CRT models needing images', 1, 99999)) | table.insert(cards, statusCard('CRTs Need Images', crtNoImage, 'Category:CRT models needing images', 1, 99999)) | ||
-- | -- AV stubs: yellow/green (warning at 1, no red) | ||
table.insert(cards, statusCard(' | table.insert(cards, statusCard('AV Device Stubs', avStubs, 'Category:AV device stubs', 1, 99999)) | ||
-- Documents: yellow/green (warning at 1, no red) | |||
table.insert(cards, statusCard('Docs Missing Content', docsMissingContent, 'Category:Documents missing content', 1, 99999)) | |||
table.insert(cards, statusCard('Orphaned Docs', docsOrphaned, 'Category:Orphaned documents', 1, 99999)) | |||
-- No series: informational only (gray), not an issue | -- No series: informational only (gray), not an issue | ||
table.insert(cards, statusCard('CRTs No Series', crtNoSeries, 'Category:CRTs without series', nil, nil, 'info')) | table.insert(cards, statusCard('CRTs No Series', crtNoSeries, 'Category:CRTs without series', nil, nil, 'info')) | ||
local output = '<div class="maintenance-status-grid">\n' | local output = '<div class="maintenance-status-grid">\n' | ||
| Line 271: | Line 317: | ||
return tostring(totalIssues) | return tostring(totalIssues) | ||
end | |||
-- List missing brand pages for a detailed view | |||
function p.listMissingBrandPages(frame) | |||
local missingBrands = {} | |||
local checkedBrands = {} | |||
-- Get all brands from CRT models | |||
local crtBrandQuery = frame:preprocess('{{#ask:[[Category:CRT models]][[Has brand::+]]|?Has brand|format=broadtable|headers=hide|link=none|mainlabel=-|limit=500|searchlabel=}}') | |||
if crtBrandQuery then | |||
for cell in crtBrandQuery:gmatch('<td[^>]*>(.-)</td>') do | |||
local brand = trim(cell:gsub('<[^>]+>', '')) | |||
if brand and brand ~= '' and not checkedBrands[brand] then | |||
checkedBrands[brand] = true | |||
local title = mw.title.new(brand) | |||
if title and not title.exists then | |||
table.insert(missingBrands, brand) | |||
end | |||
end | |||
end | |||
end | |||
-- Get all brands from AV devices | |||
local avBrandQuery = frame:preprocess('{{#ask:[[Category:AV devices]][[Has brand::+]]|?Has brand|format=broadtable|headers=hide|link=none|mainlabel=-|limit=500|searchlabel=}}') | |||
if avBrandQuery then | |||
for cell in avBrandQuery:gmatch('<td[^>]*>(.-)</td>') do | |||
local brand = trim(cell:gsub('<[^>]+>', '')) | |||
if brand and brand ~= '' and not checkedBrands[brand] then | |||
checkedBrands[brand] = true | |||
local title = mw.title.new(brand) | |||
if title and not title.exists then | |||
table.insert(missingBrands, brand) | |||
end | |||
end | |||
end | |||
end | |||
table.sort(missingBrands) | |||
if #missingBrands == 0 then | |||
return "✓ ''All brand pages exist.''" | |||
end | |||
local output = {} | |||
for _, brand in ipairs(missingBrands) do | |||
-- Count how many products use this brand | |||
local crtCount = getCount(frame, '[[Category:CRT models]][[Has brand::' .. brand .. ']]') | |||
local avCount = getCount(frame, '[[Category:AV devices]][[Has brand::' .. brand .. ']]') | |||
local totalCount = crtCount + avCount | |||
table.insert(output, '* [[' .. brand .. ']] — ' .. totalCount .. ' products') | |||
end | |||
return table.concat(output, '\n') | |||
end | end | ||
return p | return p | ||