mNo edit summary
mNo edit summary
Line 1: Line 1:
local p = {}
local p = {}
local cargo = mw.ext.cargo
local cargo = mw.ext.cargo
local x =
{
    { "", "", "Hero of the Federation", "", "" },
    { "M.I. Bronze Star", "M.I. Cross", "Medal of Valour", "Legion of Merit", "M.I. Silver Star" },
    { "Superior Command Commendation", "Distinguished Service Commendation", "Veterans Commendation", "Prisoner of War Commendation", "Emergency First Aid Commendation" },
    { "Professional Development Commendation", "Meritorious Service Commendation", "Good Conduct Commendation", "Humitarian Aid Commendation", "M.I. Reconnaissance Commendation" },
    { "Combat Commendation", "PsyOps Accomplishment Commendation", "Medical Accomplishment Commendation", "Engineering Accomplishment Commendation", "Purple Heart" },
    { "", "", "Veteran's Ribbon", "", "" }
}


function p.Main( frame )
function p.Main( frame )
Line 18: Line 28:
     }
     }
     local results = cargo.query( tables, fields, args )
     local results = cargo.query( tables, fields, args )
    for k, r in pairs(x) do
        table.insert(t, "<tr>")
        for k2, r2 in pairs(r) do
            table.insert(t, "<td>")
           
            table.insert(t, "</td>")
        end
        table.insert(t, "</tr>")
    end
     for r = 1, #results do
     for r = 1, #results do
         local result = results[r]
         local result = results[r]
         table.insert(t, result.Commendation .. " = " .. result["COUNT(*)"])
         table.insert(t, result.Commendation .. " = " .. result["COUNT(*)"])
     end
     end
     return table.concat(t, '<br>')
     return table.concat(t, '')
end
end


return p
return p

Revision as of 19:42, 8 November 2022

Documentation for this module may be created at Module:Commendations/doc

local p = {}
local cargo = mw.ext.cargo

local x = 
{
    { "", "", "Hero of the Federation", "", "" },
    { "M.I. Bronze Star", "M.I. Cross", "Medal of Valour", "Legion of Merit", "M.I. Silver Star" },
    { "Superior Command Commendation", "Distinguished Service Commendation", "Veterans Commendation", "Prisoner of War Commendation", "Emergency First Aid Commendation" },
    { "Professional Development Commendation", "Meritorious Service Commendation", "Good Conduct Commendation", "Humitarian Aid Commendation", "M.I. Reconnaissance Commendation" },
    { "Combat Commendation", "PsyOps Accomplishment Commendation", "Medical Accomplishment Commendation", "Engineering Accomplishment Commendation", "Purple Heart" },
    { "", "", "Veteran's Ribbon", "", "" }
}

function p.Main( frame )
    local t = {}
    local tables = 'Commendations'
    local fields = 'Commendation, COUNT(*)'
    -- optional parameters are grouped in one table
    -- you can omit any or all of them, except join if you use more than one table
    local args = {
        --where = '',
        --join = 'table1.fieldA = table2.fieldB,table2.fieldC=table3.fieldD, etc.',
        groupBy = 'Commendation',
        --having = 'table1.fieldG="some value", etc.',
        --orderBy = 'table2.fieldF, etc.',
        --limit = some number,
        --offset = some number,
    }
    local results = cargo.query( tables, fields, args )
    for k, r in pairs(x) do
        table.insert(t, "<tr>")
        for k2, r2 in pairs(r) do
            table.insert(t, "<td>")
            
            table.insert(t, "</td>")
        end
        table.insert(t, "</tr>")
    end
    for r = 1, #results do
        local result = results[r]
        table.insert(t, result.Commendation .. " = " .. result["COUNT(*)"])
    end
    return table.concat(t, '')
end

return p


Categories: