Module:ListPeople: Difference between revisions
Appearance
Created page with "local p = {} local cargo = mw.ext.cargo function p.get() local peopleSet = {} -- Fetch Composer values local composerResults = cargo.query('Compositions', 'Composer', { groupBy = 'Composer', limit = 1000 }) -- Fetch Arranger values local arrangerResults = cargo.query('Compositions', 'Arranger', { groupBy = 'Arranger', limit = 1000 }) local function addNames(field) for _, row in ipairs(field) do..." |
No edit summary |
||
Line 18: | Line 18: | ||
}) | }) | ||
local function addNames( | local function addNames(resultTable) | ||
for _, row in ipairs( | for _, row in ipairs(resultTable) do | ||
for name in mw.text.gsplit( | local fieldValue = row[1] or '' | ||
for name in mw.text.gsplit(fieldValue, '[,;]') do | |||
name = mw.text.trim(name) | name = mw.text.trim(name) | ||
if name ~= '' then | if name ~= '' then |
Revision as of 03:24, 23 July 2025
Documentation for this module may be created at Module:ListPeople/doc
local p = {}
local cargo = mw.ext.cargo
function p.get()
local peopleSet = {}
-- Fetch Composer values
local composerResults = cargo.query('Compositions', 'Composer', {
groupBy = 'Composer',
limit = 1000
})
-- Fetch Arranger values
local arrangerResults = cargo.query('Compositions', 'Arranger', {
groupBy = 'Arranger',
limit = 1000
})
local function addNames(resultTable)
for _, row in ipairs(resultTable) do
local fieldValue = row[1] or ''
for name in mw.text.gsplit(fieldValue, '[,;]') do
name = mw.text.trim(name)
if name ~= '' then
peopleSet[name] = true
end
end
end
end
addNames(composerResults)
addNames(arrangerResults)
-- Convert to sorted list
local peopleList = {}
for name, _ in pairs(peopleSet) do
table.insert(peopleList, name)
end
table.sort(peopleList)
-- Build output
local out = {}
for _, name in ipairs(peopleList) do
table.insert(out, '* [[' .. name .. ']]')
end
return table.concat(out, '\n')
end
return p