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 | ||
-- | -- pre-computed brand category pages with semantic properties. | ||
-- | -- Much faster than scanning all CRT model pages. | ||
local p = {} | local p = {} | ||
| Line 21: | Line 18: | ||
local linkType = trim(args.link) | local linkType = trim(args.link) | ||
-- Query | -- Query brand category pages (fast - only queries category pages, not all CRTs) | ||
local queryWikitext = | local queryWikitext = | ||
'{{#ask:\n' .. | '{{#ask:\n' .. | ||
' [[ | ' [[Is CRT brand category::Yes]]\n' .. | ||
' |?Brand name\n' .. | |||
' |? | ' |format=broadtable\n' .. | ||
' |format= | ' |headers=hide\n' .. | ||
' | | |||
' |link=none\n' .. | ' |link=none\n' .. | ||
' |mainlabel=-\n' .. | ' |mainlabel=-\n' .. | ||
' |limit= | ' |limit=500\n' .. | ||
' |searchlabel=\n' .. | ' |searchlabel=\n' .. | ||
'}}' | '}}' | ||
| Line 39: | Line 33: | ||
local queryResult = frame:preprocess(queryWikitext) | local queryResult = frame:preprocess(queryWikitext) | ||
-- Extract | -- Extract brand names from result | ||
local brandsList = {} | local brandsList = {} | ||
if queryResult then | if queryResult then | ||
for cellContent in queryResult:gmatch('<td[^>]*>(.-)</td>') do | |||
for | local brand = trim(cellContent:gsub('<[^>]+>', '')) | ||
if brand and brand ~= '' then | |||
table.insert(brandsList, brand) | |||
end | end | ||
end | end | ||