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
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
 
(One intermediate revision by the same user not shown)
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.


local p = {}
local p = {}
Line 19: 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)
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=broadtable\n' ..
' |headers=hide\n' ..
' |headers=hide\n' ..
' |link=none\n' ..
' |link=none\n' ..
' |mainlabel=-\n' ..
' |mainlabel=-\n' ..
' |limit=5000\n' ..
' |limit=500\n' ..
' |searchlabel=\n' ..
' |searchlabel=\n' ..
'}}'
'}}'
Line 35: 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 = {}
Line 42: Line 39:
for cellContent in queryResult:gmatch('<td[^>]*>(.-)</td>') do
for cellContent in queryResult:gmatch('<td[^>]*>(.-)</td>') do
local brand = trim(cellContent:gsub('<[^>]+>', ''))
local brand = trim(cellContent:gsub('<[^>]+>', ''))
if brand and brand ~= '' and not seen[brand] then
if brand and brand ~= '' then
seen[brand] = true
table.insert(brandsList, brand)
table.insert(brandsList, brand)
end
end
MediaWiki Appliance - Powered by TurnKey Linux