local p = {}
-- Non-non dynamic module, no inputs ▼
-- Utility function to clean up number strings by removing commas
local function cleanNumberString(value)
if type(value) == "string" then ▼
return value:gsub(",", "")
return value
▲-- Non-dynamic module, no inputs
function p.main()
-- Returnsreturns only directly needed parametersparameter needed for the row,
-- other parameters are determined by subqueries of chained pages
local query = {
'[[-Sold item.Shop sell price::~*+]]',
'?=Name',
'?-Sold item.Shop sell price=ShopValue',
'?Value=InfoboxValue',
'limit = 10000500',
}
'order = asc'
}
local results = mw.smw.ask(query)
for _, item in ipairs(results) do ▼
local shopValues = item.ShopValue -- Could be an array or a single value
if shopValues ~= nil then
if type(shopValues) == "string" then
shopValues = { shopValues } -- Normalize to a table for consistency
end
local infoboxValueout = item.InfoboxValue{}
▲ for _, item in ipairs(results) do
if infoboxValue == nil then
infoboxValuelocal i = tonumber (cleanNumberString(item.InfoboxValue )) ▼
infoboxValue = 0
local s = item.ShopValue
elseif type(infoboxValue)=='string' then ▼
▲ infoboxValue = tonumber(cleanNumberString(item.InfoboxValue))
▲ if type( values) == "'string "' then
if i==tonumber(s) or not(tonumber(s)) then
add = false
end
▲ elseif type( infoboxValues)==' stringtable' then
local hasMismatch = false
for _, itemshop in ipairs( outs) do ▼
if i==tonumber(shop) or not(tonumber(shop)) then
for _, shopValue in ipairs(shopValues) do
add = false
if shopValue ~= "N/A" then
-- Compare numeric values
end
local cleanShopValue = cleanNumberString(shopValue)
end
local numericShopValue = tonumber(cleanShopValue)
if add then
if numericShopValue and numericShopValue ~= infoboxValue then
table.insert(out, item .Name) ▼
hasMismatch = true
end
break
end
end
return table.concat(out, '<br>')
end
-- Add the item to the output if any shopValue mismatched InfoboxValue
if hasMismatch then
▲ table.insert(out, item)
end
-- Format the output to display each item's details
local output = {}
▲ for _, item in ipairs(out) do
table.insert(output, mw.text.jsonEncode(item)) -- Convert each item to a JSON string for display
return table.concat(output, '<br>') -- Concatenate the JSON representations with a line break
end
|