Jump to content

Module:ListPeople

From Benvenuti Music Library
Revision as of 03:21, 23 July 2025 by Craig.dabelstein (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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(field)
        for _, row in ipairs(field) do
            for name in mw.text.gsplit(row[1] or '', '[,;]') 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