Module:CRTBrandList: Difference between revisions

Fix: Use format=plainlist instead of broadtable to handle large result sets efficiently - broadtable was causing truncation with 2000+ CRT models (via update-page on MediaWiki MCP Server)
Tag: Reverted
Revert to original category-based approach - direct queries don't scale well with 2000+ CRT models (via update-page on MediaWiki MCP Server)
Tag: Manual revert
 
Line 1: Line 1:
-- Module:CRTBrandList
-- Module:CRTBrandList
-- Dynamically generates a list of CRT brand buttons by querying
-- Dynamically generates a list of CRT brand buttons by querying
-- distinct brands from actual CRT model pages.
-- pre-computed brand category pages with semantic properties.
-- This approach ensures all brands with at least one CRT model appear,
-- Much faster than scanning all CRT model pages.
-- even if they don't have a dedicated brand category page.
--
-- Uses format=plainlist for efficiency with large datasets (2000+ CRTs).


local p = {}
local p = {}
Line 21: Line 18:
local linkType = trim(args.link)
local linkType = trim(args.link)
-- Query distinct brands from actual CRT model pages
-- Query brand category pages (fast - only queries category pages, not all CRTs)
-- Using plainlist format with custom separator for efficient parsing
local queryWikitext =
local queryWikitext =
'{{#ask:\n' ..
'{{#ask:\n' ..
' [[Category:CRT models]]\n' ..
' [[Is CRT brand category::Yes]]\n' ..
' [[Has brand::+]]\n' ..
' |?Brand name\n' ..
' |?Has brand\n' ..
' |format=broadtable\n' ..
' |format=plainlist\n' ..
' |headers=hide\n' ..
' |sep=@@SEP@@\n' ..
' |valuesep=@@VAL@@\n' ..
' |link=none\n' ..
' |link=none\n' ..
' |mainlabel=-\n' ..
' |mainlabel=-\n' ..
' |limit=5000\n' ..
' |limit=500\n' ..
' |searchlabel=\n' ..
' |searchlabel=\n' ..
'}}'
'}}'
Line 39: Line 33:
local queryResult = frame:preprocess(queryWikitext)
local queryResult = frame:preprocess(queryWikitext)
-- Extract and deduplicate brand names from result
-- Extract brand names from result
local seen = {}
local brandsList = {}
local brandsList = {}
if queryResult then
if queryResult then
-- Split by our custom separator
for cellContent in queryResult:gmatch('<td[^>]*>(.-)</td>') do
for entry in (queryResult .. '@@SEP@@'):gmatch('(.-)@@SEP@@') do
local brand = trim(cellContent:gsub('<[^>]+>', ''))
-- Each entry might have multiple values separated by @@VAL@@
if brand and brand ~= '' then
for brand in (entry .. '@@VAL@@'):gmatch('(.-)@@VAL@@') do
table.insert(brandsList, brand)
brand = trim(brand)
if brand and brand ~= '' and not seen[brand] then
seen[brand] = true
table.insert(brandsList, brand)
end
end
end
end
end
MediaWiki Appliance - Powered by TurnKey Linux