Module:CRTBrandList: Difference between revisions
Update to query brands directly from CRT model pages (like AVBrandList) instead of requiring brand category pages - ensures all CRT brands appear (via update-page on MediaWiki MCP Server) Tag: Reverted |
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 |
||
| Line 4: | Line 4: | ||
-- This approach ensures all brands with at least one CRT model appear, | -- This approach ensures all brands with at least one CRT model appear, | ||
-- even if they don't have a dedicated brand category page. | -- 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 20: | Line 22: | ||
-- Query distinct brands from actual CRT model pages | -- Query distinct brands from actual CRT model pages | ||
-- Using plainlist format with custom separator for efficient parsing | |||
local queryWikitext = | local queryWikitext = | ||
'{{#ask:\n' .. | '{{#ask:\n' .. | ||
| Line 25: | Line 28: | ||
' [[Has brand::+]]\n' .. | ' [[Has brand::+]]\n' .. | ||
' |?Has brand\n' .. | ' |?Has brand\n' .. | ||
' |format= | ' |format=plainlist\n' .. | ||
' | | ' |sep=@@SEP@@\n' .. | ||
' |valuesep=@@VAL@@\n' .. | |||
' |link=none\n' .. | ' |link=none\n' .. | ||
' |mainlabel=-\n' .. | ' |mainlabel=-\n' .. | ||
| Line 40: | Line 44: | ||
if queryResult then | if queryResult then | ||
for | -- Split by our custom separator | ||
for entry in (queryResult .. '@@SEP@@'):gmatch('(.-)@@SEP@@') do | |||
-- Each entry might have multiple values separated by @@VAL@@ | |||
for brand in (entry .. '@@VAL@@'):gmatch('(.-)@@VAL@@') do | |||
brand = trim(brand) | |||
if brand and brand ~= '' and not seen[brand] then | |||
seen[brand] = true | |||
table.insert(brandsList, brand) | |||
end | |||
end | end | ||
end | end | ||