Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Revision as of 12:53, 22 May 2026 by Esportsamaze (talk | contribs) (Created page with "local p = {} local cargo = mw.ext.cargo local function clean(s) if not s then return nil end local res = s:gsub("^%s*(.-)%s*$", "%1") return res == "" and nil or res end local function parseLine(line) local data = {} for pair in string.gmatch(line, "[^,]+") do local key, val = string.match(pair, "^%s*([^=]+)%s*=%s*(.-)%s*$") if key and val then data[string.lower(key)] = val end end return data end function p.store(frame)...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

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

local function clean(s)
    if not s then return nil end
    local res = s:gsub("^%s*(.-)%s*$", "%1")
    return res == "" and nil or res
end

local function parseLine(line)
    local data = {}
    for pair in string.gmatch(line, "[^,]+") do
        local key, val = string.match(pair, "^%s*([^=]+)%s*=%s*(.-)%s*$")
        if key and val then data[string.lower(key)] = val end
    end
    return data
end

function p.store(frame)
    local args = frame:getParent().args
    local statType = string.lower(clean(args.type) or "team")
    
    local meta = {
        tournament = clean(args.tournament),
        tier       = clean(args.tier),
        end_date   = clean(args.end_date)
    }

    local tableName = (statType == "player") and "RankingData_Player" or "RankingData_Team"
    
    for i = 1, 200 do
        local line = args[tostring(i)]
        if line and clean(line) then
            local rowData = parseLine(line)
            local storeData = {
                tournament = meta.tournament,
                tier       = meta.tier,
                end_date   = meta.end_date
            }
            
            if statType == "team" then
                storeData.team = rowData.team
                storeData.rank = tonumber(rowData.rank)
            elseif statType == "player" then
                storeData.player      = rowData.player
                storeData.team        = rowData.team
                storeData.finishes    = tonumber(rowData.finishes) or 0
                storeData.mvp_tourney = tonumber(rowData.mvp_tourney) or 0
                storeData.igl         = tonumber(rowData.igl) or 0
                storeData.survivor    = tonumber(rowData.survivor) or 0
                storeData.mvp_finals  = tonumber(rowData.mvp_finals) or 0
                storeData.emerging    = tonumber(rowData.emerging) or 0
            end
            
            if cargo and cargo.store then cargo.store(tableName, storeData) end
        end
    end
    return "<div style='display:none;'>Ranking Event Stored.</div>"
end

return p