Module:BrandSeries: Difference between revisions
Fix link rendering - use wikitext table format instead of mw.html (via update-page on MediaWiki MCP Server) |
Remove Browse column, add Unassigned row for models without series (via update-page on MediaWiki MCP Server) |
||
| Line 57: | Line 57: | ||
end | end | ||
end | end | ||
-- Query count of models with NO series assigned | |||
local unassignedQuery = string.format( | |||
'{{#ask:[[Category:CRT models]][[Has brand::%s]][[Has series::!+]]|format=count}}', | |||
brand | |||
) | |||
local unassignedResult = frame:preprocess(unassignedQuery) | |||
local unassignedCount = tonumber(trim(unassignedResult)) or 0 | |||
-- Convert to sorted array | -- Convert to sorted array | ||
| Line 70: | Line 78: | ||
table.sort(rows, function(a, b) return a.series < b.series end) | table.sort(rows, function(a, b) return a.series < b.series end) | ||
-- If no series found | -- If no series found and no unassigned models, return nothing | ||
if #rows == 0 then | if #rows == 0 and unassignedCount == 0 then | ||
return "" | return "" | ||
end | end | ||
| Line 78: | Line 86: | ||
local lines = {} | local lines = {} | ||
table.insert(lines, '{| class="wikitable"') | table.insert(lines, '{| class="wikitable"') | ||
table.insert(lines, '! Series !! Count | table.insert(lines, '! Series !! Count') | ||
-- Series rows | |||
for _, row in ipairs(rows) do | for _, row in ipairs(rows) do | ||
local seriesLink = '[[' .. row.series .. ']]' | local seriesLink = '[[' .. row.series .. ']]' | ||
table.insert(lines, '|-') | table.insert(lines, '|-') | ||
table.insert(lines, '| ' .. seriesLink .. ' || ' .. tostring(row.count) .. ' || | table.insert(lines, '| ' .. seriesLink .. ' || ' .. tostring(row.count)) | ||
end | |||
-- Unassigned row (if any) | |||
if unassignedCount > 0 then | |||
table.insert(lines, '|-') | |||
table.insert(lines, "| ''(Unassigned)'' || " .. tostring(unassignedCount)) | |||
end | end | ||