Module:CRTBrandList: Difference between revisions
Implement pagination to handle server-side query limits (via update-page on MediaWiki MCP Server) |
Rewrite to query pre-computed category semantic properties instead of scanning all CRT pages (via update-page on MediaWiki MCP Server) |
||
| 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 12: | Line 12: | ||
if s == '' then return nil end | if s == '' then return nil end | ||
return s | return s | ||
end | end | ||
| Line 30: | Line 18: | ||
local linkType = trim(args.link) | local linkType = trim(args.link) | ||
local | -- Query brand category pages (fast - only queries category pages, not all CRTs) | ||
local queryWikitext = | |||
'{{#ask:\n' .. | |||
' [[Is CRT brand category::Yes]]\n' .. | |||
' |?Brand name\n' .. | |||
' |format=broadtable\n' .. | |||
' |headers=hide\n' .. | |||
' |link=none\n' .. | |||
' |mainlabel=-\n' .. | |||
' |limit=500\n' .. | |||
' |searchlabel=\n' .. | |||
'}}' | |||
local queryResult = frame:preprocess(queryWikitext) | |||
-- Extract brand names from result | |||
local brandsList = {} | local brandsList = {} | ||
if queryResult then | |||
for cellContent in queryResult:gmatch('<td[^>]*>(.-)</td>') do | |||
local brand = trim(cellContent:gsub('<[^>]+>', '')) | |||
if brand and brand ~= '' then | |||
table.insert(brandsList, brand) | |||
end | end | ||
end | end | ||
end | end | ||