mNo edit summary |
mNo edit summary |
||
Line 28: | Line 28: | ||
function query(args) | function query(args) | ||
local whereStr = '' | local whereStr = '' | ||
if args.type then whereStr = whereStr .. 'db_type HOLDS "' .. args.type .. '"' end | |||
if args.name then whereStr = whereStr .. (whereStr ~= '' and ' AND ' or '') .. '_pageName LIKE "%' .. args.name .. '%"' end | if args.name then whereStr = whereStr .. (whereStr ~= '' and ' AND ' or '') .. '_pageName LIKE "%' .. args.name .. '%"' end |
Latest revision as of 17:00, 26 March 2024
Documentation for this module may be created at Module:Companies/Search/doc
local getArgs = require('Module:Arguments').getArgs
local cargo = mw.ext.cargo
local limit = 100000
local CompaniesList = {}
function CompaniesList.main(frame)
local args = getArgs(frame)
local results = query( args)
if #results > 0 then
local container = mw.html.create('div'):attr('id', 'companies-search-container')
local ul = mw.html.create('ul')
for r = 1, #results do
ul:node(mw.html.create('li'):node('[[' .. results[r]._pageName .. ']]'))
end
container:node(ul)
return container
end
end
function query(args)
local whereStr = ''
if args.type then whereStr = whereStr .. 'db_type HOLDS "' .. args.type .. '"' end
if args.name then whereStr = whereStr .. (whereStr ~= '' and ' AND ' or '') .. '_pageName LIKE "%' .. args.name .. '%"' end
local tables = 'Companies'
local fields = '_pageName'
local cargoArgs = {
where = whereStr,
orderBy = '_pageName DESC',
limit = limit
}
local results = cargo.query(tables, fields, cargoArgs)
return results
end
return CompaniesList