Przejdź do zawartości

Moduł:HistoriaWystepow: Różnice pomiędzy wersjami

Z Encyklopedia Poznanskiego Sportu
Nie podano opisu zmian
Nie podano opisu zmian
Linia 13: Linia 13:
     -- =====================================================
     -- =====================================================


     local zawodnikSQL = mw.ustring.gsub(
     local zawodnikSQL =
        zawodnik,
        mw.ustring.gsub(zawodnik, "'", "''")
        "'",
        "''"
    )


     -- =====================================================
     -- =====================================================
Linia 67: Linia 64:


         limit = 5000
         limit = 5000
     }
     }


Linia 125: Linia 123:
         nowePodsumowanie()
         nowePodsumowanie()


    -- sezony
     local sezony = {}
     local sezony = {}


    -- kluby
     local kluby = {}
     local kluby = {}
    -- =====================================================
    -- REKORDY INDYWIDUALNE
    -- =====================================================
    local rekordy = {
        punkty = {
            wartosc = -1,
            mecze = {}
        },
        minuty = {
            wartosc = -1,
            mecze = {}
        },
        asysty = {
            wartosc = -1,
            mecze = {}
        },
        zbiorki = {
            wartosc = -1,
            mecze = {}
        }
    }


     -- =====================================================
     -- =====================================================
Linia 270: Linia 242:
             stat.remisy =
             stat.remisy =
                 stat.remisy + 1
                 stat.remisy + 1
        end
    end
    -- =====================================================
    -- FUNKCJA DODAJĄCA MECZ DO REKORDU
    -- =====================================================
    local function dodajDoRekordu(
        rekord,
        wartosc,
        row
    )
        wartosc =
            tonumber(wartosc or 0)
        if wartosc > rekord.wartosc then
            rekord.wartosc =
                wartosc
            rekord.mecze = {
                row
            }
        elseif wartosc == rekord.wartosc then
            table.insert(
                rekord.mecze,
                row
            )


         end
         end
Linia 314: Linia 253:
     for _, row in ipairs(rows) do
     for _, row in ipairs(rows) do


         -- -------------------------------------------------
         -- -----------------------------------------------
         -- WSZYSTKIE MECZE
         -- WSZYSTKIE
         -- -------------------------------------------------
         -- -----------------------------------------------


         dodajDoPodsumowania(
         dodajDoPodsumowania(
Linia 323: Linia 262:
         )
         )


         -- -------------------------------------------------
         -- -----------------------------------------------
         -- DOM / WYJAZD
         -- DOM / WYJAZD
         -- -------------------------------------------------
         -- -----------------------------------------------


         local d1 =
         local d1 =
Linia 352: Linia 291:
         end
         end


         -- -------------------------------------------------
         -- -----------------------------------------------
         -- SEZON
         -- SEZON
         -- -------------------------------------------------
         -- -----------------------------------------------


         local sezon =
         local sezon =
Linia 375: Linia 314:
         )
         )


         -- -------------------------------------------------
         -- -----------------------------------------------
         -- KLUB
         -- KLUB
         -- -------------------------------------------------
         -- -----------------------------------------------


         if druzyna ~= "" then
         if druzyna == "" then
            druzyna = "Brak klubu"
        end


            if not kluby[druzyna] then
        if not kluby[druzyna] then


                kluby[druzyna] =
            kluby[druzyna] =
                    nowePodsumowanie()
                nowePodsumowanie()
 
            end
 
            dodajDoPodsumowania(
                kluby[druzyna],
                row
            )


         end
         end


         -- -------------------------------------------------
         dodajDoPodsumowania(
        -- REKORDY
             kluby[druzyna],
        -- -------------------------------------------------
 
        dodajDoRekordu(
            rekordy.punkty,
            row.gol,
            row
        )
 
        dodajDoRekordu(
            rekordy.minuty,
            row.minuty,
            row
        )
 
        dodajDoRekordu(
            rekordy.asysty,
            row.asysta,
            row
        )
 
        dodajDoRekordu(
             rekordy.zbiorki,
            row.zbiorka,
             row
             row
         )
         )
Linia 429: Linia 340:
     -- =====================================================
     -- =====================================================


     local function formatujMinuty(
     local function formatujMinuty(minuty)
        minuty
    )
 
        minuty =
            tonumber(minuty or 0)


         local godziny =
         local godziny =
             math.floor(
             math.floor(minuty / 60)
                minuty / 60
            )


         local min =
         local min =
Linia 453: Linia 357:


     -- =====================================================
     -- =====================================================
     -- FORMAT MECZU DLA REKORDÓW
     -- SORTOWANIE SEZONÓW
    -- =====================================================
 
    local listaSezonow = {}
 
    for sezon, _ in pairs(sezony) do
 
        table.insert(
            listaSezonow,
            sezon
        )
 
    end
 
    table.sort(
        listaSezonow,
        function(a, b)
 
            return a > b
 
        end
    )
 
    -- =====================================================
    -- SORTOWANIE KLUBÓW
     -- =====================================================
     -- =====================================================


     local function rekordMecz(
     local listaKlubow = {}
         row
 
    for klub, _ in pairs(kluby) do
 
        table.insert(
            listaKlubow,
            klub
        )
 
    end
 
    table.sort(
         listaKlubow
     )
     )


        local d1 =
    -- =====================================================
            row.druzyna1 or ""
    -- FUNKCJA: CZY JEST MECZ DOMOWY?
    -- =====================================================


        local d2 =
    local function czyDom(row)
            row.druzyna2 or ""


         local druzyna =
         local druzyna =
             row.druzyna or ""
             row.druzyna or ""


         local przeciwnik = ""
         local d1 =
            row.druzyna1 or ""
 
        return druzyna == d1
 
    end


        if druzyna == d1 then
    -- =====================================================
    -- FUNKCJA OPISUJĄCA MECZ
    --
    -- WAŻNE:
    -- ZAWSZE GOSPODARZ – GOŚĆ
    -- =====================================================


            przeciwnik = d2
    local function rekordMecz(row)


         elseif druzyna == d2 then
         local d1 =
            row.druzyna1 or ""


             przeciwnik = d1
        local d2 =
             row.druzyna2 or ""


         else
         local data =
            row.data or ""


             przeciwnik = d2
        local wynikMeczu =
             row.wynik or ""


             if przeciwnik == "" then
        local strona =
                przeciwnik = d1
             row.strona_meczu or ""
            end


         end
         -- -----------------------------------------------
        -- FAKTYCZNY ZAPIS MECZU
        -- -----------------------------------------------


         local opis =
         local meczTekst =
             druzyna
             d1
             .. " – "
             .. " – "
             .. przeciwnik
             .. d2


         local strona =
         -- -----------------------------------------------
            row.strona_meczu or ""
        -- LINK DO STRONY MECZU
        -- -----------------------------------------------


         if strona ~= "" then
         if strona ~= "" then


             opis =
             meczTekst =
                 "[["
                 "[["
                 .. strona
                 .. strona
                 .. "|"
                 .. "|"
                 .. druzyna
                 .. d1
                 .. " – "
                 .. " – "
                 .. przeciwnik
                 .. d2
                 .. "]]"
                 .. "]]"


         end
         end


         local data =
         -- -----------------------------------------------
            row.data or ""
        -- DATA
 
         -- -----------------------------------------------
         local wynikMeczu =
            row.wynik or ""


         if data ~= "" then
         if data ~= "" then


             opis =
             meczTekst =
                 opis
                 meczTekst
                 .. " ("
                 .. " ("
                 .. data
                 .. data
Linia 525: Linia 478:


         end
         end
        -- -----------------------------------------------
        -- WYNIK
        -- -----------------------------------------------


         if wynikMeczu ~= "" then
         if wynikMeczu ~= "" then


             opis =
             meczTekst =
                 opis
                 meczTekst
                 .. " "
                 .. " "
                 .. wynikMeczu
                 .. wynikMeczu
Linia 535: Linia 492:
         end
         end


         return opis
         return meczTekst


     end
     end


     -- =====================================================
     -- =====================================================
     -- SORTOWANIE SEZONÓW
     -- REKORDY
    -- =====================================================
 
    local rekordPunkty = -1
    local rekordMinuty = -1
    local rekordAsysty = -1
    local rekordZbiorki = -1
 
    local meczePunkty = {}
    local meczeMinuty = {}
    local meczeAsysty = {}
    local meczeZbiorki = {}
 
    -- =====================================================
    -- WYSZUKIWANIE REKORDÓW
     -- =====================================================
     -- =====================================================


     local listaSezonow = {}
     for _, row in ipairs(rows) do
 
        local punkty =
            tonumber(row.gol or 0)
 
        local minuty =
            tonumber(row.minuty or 0)
 
        local asysty =
            tonumber(row.asysta or 0)
 
        local zbiorki =
            tonumber(row.zbiorka or 0)
 
        -- -----------------------------------------------
        -- PUNKTY
        -- -----------------------------------------------
 
        if punkty > rekordPunkty then
 
            rekordPunkty = punkty
 
            meczePunkty = { row }
 
        elseif punkty == rekordPunkty then
 
            table.insert(
                meczePunkty,
                row
            )
 
        end
 
        -- -----------------------------------------------
        -- MINUTY
        -- -----------------------------------------------
 
        if minuty > rekordMinuty then
 
            rekordMinuty = minuty
 
            meczeMinuty = { row }
 
        elseif minuty == rekordMinuty then
 
            table.insert(
                meczeMinuty,
                row
            )
 
        end
 
        -- -----------------------------------------------
        -- ASYSTY
        -- -----------------------------------------------
 
        if asysty > rekordAsysty then
 
            rekordAsysty = asysty
 
            meczeAsysty = { row }
 
        elseif asysty == rekordAsysty then
 
            table.insert(
                meczeAsysty,
                row
            )
 
        end
 
        -- -----------------------------------------------
        -- ZBIÓRKI
        -- -----------------------------------------------


    for sezon, _ in pairs(sezony) do
        if zbiorki > rekordZbiorki then


        table.insert(
             rekordZbiorki = zbiorki
             listaSezonow,
            sezon
        )


    end
            meczeZbiorki = { row }


    table.sort(
         elseif zbiorki == rekordZbiorki then
         listaSezonow,
        function(a, b)


             return a > b
             table.insert(
                meczeZbiorki,
                row
            )


         end
         end
     )
 
     end


     -- =====================================================
     -- =====================================================
     -- SORTOWANIE KLUBÓW
     -- LISTA MECZÓW W REKORDZIE
     -- =====================================================
     -- =====================================================


     local listaKlubow = {}
     local function listaRekordow(lista)


    for klub, _ in pairs(kluby) do
        local wynikRekordu = {}


         table.insert(
         for _, row in ipairs(lista) do
            listaKlubow,
            klub
        )


    end
            table.insert(
                wynikRekordu,
                rekordMecz(row)
            )


    table.sort(
         end
         listaKlubow,
        function(a, b)


            return mw.ustring.lower(a)
        return table.concat(
                < mw.ustring.lower(b)
            wynikRekordu,
            "<br>"
        )


        end
    end
    )


     -- =====================================================
     -- =====================================================
Linia 593: Linia 635:


     local wynik = {}
     local wynik = {}
    -- =====================================================
    -- HISTORIA
    -- =====================================================


     table.insert(
     table.insert(
Linia 643: Linia 689:
     )
     )


     -- Występy
     -- WYSTĘPY


     table.insert(wynik, "|-")
     table.insert(wynik, "|-")
Linia 651: Linia 697:
     table.insert(wynik, "| '''" .. wyjazd.wystepy .. "'''")
     table.insert(wynik, "| '''" .. wyjazd.wystepy .. "'''")


     -- Zwycięstwa
     -- ZWYCIĘSTWA


     table.insert(wynik, "|-")
     table.insert(wynik, "|-")
Linia 659: Linia 705:
     table.insert(wynik, "| '''" .. wyjazd.zwyciestwa .. "'''")
     table.insert(wynik, "| '''" .. wyjazd.zwyciestwa .. "'''")


     -- Porażki
     -- PORAŻKI


     table.insert(wynik, "|-")
     table.insert(wynik, "|-")
Linia 667: Linia 713:
     table.insert(wynik, "| '''" .. wyjazd.porazki .. "'''")
     table.insert(wynik, "| '''" .. wyjazd.porazki .. "'''")


     -- Remisy
     -- REMISY


     table.insert(wynik, "|-")
     table.insert(wynik, "|-")
Linia 675: Linia 721:
     table.insert(wynik, "| '''" .. wyjazd.remisy .. "'''")
     table.insert(wynik, "| '''" .. wyjazd.remisy .. "'''")


     -- Punkty
     -- PUNKTY


     table.insert(wynik, "|-")
     table.insert(wynik, "|-")
Linia 683: Linia 729:
     table.insert(wynik, "| '''" .. wyjazd.punkty .. "'''")
     table.insert(wynik, "| '''" .. wyjazd.punkty .. "'''")


     -- Minuty
     -- MINUTY


     table.insert(wynik, "|-")
     table.insert(wynik, "|-")
Linia 691: Linia 737:
     table.insert(wynik, "| '''" .. formatujMinuty(wyjazd.minuty) .. "'''")
     table.insert(wynik, "| '''" .. formatujMinuty(wyjazd.minuty) .. "'''")


     -- Asysty
     -- ASYSTY


     table.insert(wynik, "|-")
     table.insert(wynik, "|-")
Linia 699: Linia 745:
     table.insert(wynik, "| '''" .. wyjazd.asysty .. "'''")
     table.insert(wynik, "| '''" .. wyjazd.asysty .. "'''")


     -- Zbiórki
     -- ZBIÓRKI


     table.insert(wynik, "|-")
     table.insert(wynik, "|-")
Linia 715: Linia 761:
     table.insert(wynik, "| '''" .. wyjazd.eval .. "'''")
     table.insert(wynik, "| '''" .. wyjazd.eval .. "'''")


     -- Plus/minus
     -- PLUS/MINUS


     table.insert(wynik, "|-")
     table.insert(wynik, "|-")
Linia 734: Linia 780:


     -- =====================================================
     -- =====================================================
     -- NAJLEPSZE WYSTĘPY
     -- REKORDY ZAWODNIKA
     -- =====================================================
     -- =====================================================


Linia 764: Linia 810:
     table.insert(
     table.insert(
         wynik,
         wynik,
         "! Mecz"
         "! Mecz / mecze"
     )
     )


     -- -----------------------------------------------------
     -- PUNKTY
    -- NAJWIĘCEJ PUNKTÓW
    -- -----------------------------------------------------


     table.insert(
     table.insert(wynik, "|-")
        wynik,
    table.insert(wynik, "! 🏀 Najwięcej punktów")
        "|-"
    table.insert(wynik, "| '''" .. rekordPunkty .. "'''")
     )
     table.insert(wynik, "| " .. listaRekordow(meczePunkty))


     table.insert(
     -- MINUTY
        wynik,
        "! 🏀 Najwięcej punktów"
    )


     table.insert(
     table.insert(wynik, "|-")
        wynik,
    table.insert(wynik, "! ⏱ Najwięcej minut")
        "| '''"
    table.insert(wynik, "| '''" .. formatujMinuty(rekordMinuty) .. "'''")
        .. rekordy.punkty.wartosc
     table.insert(wynik, "| " .. listaRekordow(meczeMinuty))
        .. "'''"
     )


     local meczePunkty = {}
     -- ASYSTY


     for _, row in ipairs(
     table.insert(wynik, "|-")
        rekordy.punkty.mecze
    table.insert(wynik, "! 🎯 Najwięcej asyst")
     ) do
    table.insert(wynik, "| '''" .. rekordAsysty .. "'''")
     table.insert(wynik, "| " .. listaRekordow(meczeAsysty))


        table.insert(
    -- ZBIÓRKI
            meczePunkty,
            rekordMecz(row)
        )


    end
     table.insert(wynik, "|-")
 
     table.insert(wynik, "! 🏀 Najwięcej zbiórek")
    table.insert(
     table.insert(wynik, "| '''" .. rekordZbiorki .. "'''")
        wynik,
     table.insert(wynik, "| " .. listaRekordow(meczeZbiorki))
        "| "
        .. table.concat(
            meczePunkty,
            "<br>"
        )
    )
 
    -- -----------------------------------------------------
    -- NAJWIĘCEJ MINUT
    -- -----------------------------------------------------
 
    table.insert(
        wynik,
        "|-"
    )
 
    table.insert(
        wynik,
        "! ⏱️ Najwięcej minut"
    )
 
    table.insert(
        wynik,
        "| '''"
        .. formatujMinuty(
            rekordy.minuty.wartosc
        )
        .. "'''"
    )
 
    local meczeMinuty = {}
 
    for _, row in ipairs(
        rekordy.minuty.mecze
    ) do
 
        table.insert(
            meczeMinuty,
            rekordMecz(row)
        )
 
    end
 
    table.insert(
        wynik,
        "| "
        .. table.concat(
            meczeMinuty,
            "<br>"
        )
    )
 
    -- -----------------------------------------------------
    -- NAJWIĘCEJ ASYST
    -- -----------------------------------------------------
 
    table.insert(
        wynik,
        "|-"
    )
 
    table.insert(
        wynik,
        "! 🎯 Najwięcej asyst"
    )
 
    table.insert(
        wynik,
        "| '''"
        .. rekordy.asysty.wartosc
        .. "'''"
    )
 
    local meczeAsysty = {}
 
    for _, row in ipairs(
        rekordy.asysty.mecze
    ) do
 
        table.insert(
            meczeAsysty,
            rekordMecz(row)
        )
 
    end
 
    table.insert(
        wynik,
        "| "
        .. table.concat(
            meczeAsysty,
            "<br>"
        )
    )
 
    -- -----------------------------------------------------
    -- NAJWIĘCEJ ZBIÓREK
    -- -----------------------------------------------------
 
     table.insert(
        wynik,
        "|-"
    )
 
     table.insert(
        wynik,
        "! 🏀 Najwięcej zbiórek"
    )
 
     table.insert(
        wynik,
        "| '''"
        .. rekordy.zbiorki.wartosc
        .. "'''"
    )
 
    local meczeZbiorki = {}
 
    for _, row in ipairs(
        rekordy.zbiorki.mecze
    ) do
 
        table.insert(
            meczeZbiorki,
            rekordMecz(row)
        )
 
    end
 
     table.insert(
        wynik,
        "| "
        .. table.concat(
            meczeZbiorki,
            "<br>"
        )
    )


     table.insert(
     table.insert(
Linia 952: Linia 852:


     -- =====================================================
     -- =====================================================
     -- PODSUMOWANIE KLUBÓW
     -- PODSUMOWANIE SEZONÓW
     -- =====================================================
     -- =====================================================


     table.insert(
     table.insert(
         wynik,
         wynik,
         "=== Podsumowanie według klubu ==="
         "=== Podsumowanie sezonów ==="
     )
     )


Linia 970: Linia 870:
     )
     )


     table.insert(
     table.insert(wynik, "! Sezon")
        wynik,
     table.insert(wynik, "! Występy")
        "! Klub"
     table.insert(wynik, "! Zwycięstwa")
    )
     table.insert(wynik, "! Porażki")
 
     table.insert(wynik, "! Remisy")
     table.insert(
     table.insert(wynik, "! Punkty")
        wynik,
     table.insert(wynik, "! Minuty")
        "! Występy"
     table.insert(wynik, "! Asysty")
    )
     table.insert(wynik, "! Zbiórki")
 
     table.insert(wynik, "! EVAL")
     table.insert(
     table.insert(wynik, "! +/-")
        wynik,
        "! Zwycięstwa"
    )
 
     table.insert(
        wynik,
        "! Porażki"
    )
 
     table.insert(
        wynik,
        "! Remisy"
    )
 
     table.insert(
        wynik,
        "! Punkty"
    )
 
     table.insert(
        wynik,
        "! Minuty"
    )
 
     table.insert(
        wynik,
        "! Asysty"
     )
 
     table.insert(
        wynik,
        "! Zbiórki"
     )


    table.insert(
     for _, sezon in ipairs(listaSezonow) do
        wynik,
        "! EVAL"
    )
 
    table.insert(
        wynik,
        "! +/-"
    )
 
     for _, klub in ipairs(
        listaKlubow
    ) do


         local stat =
         local stat =
             kluby[klub]
             sezony[sezon]


         table.insert(
         table.insert(wynik, "|-")
            wynik,
            "|-"
        )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| '''"
             "| '''" .. sezon .. "'''"
            .. klub
            .. "'''"
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. stat.wystepy
            .. stat.wystepy
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. stat.zwyciestwa
            .. stat.zwyciestwa
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. stat.porazki
            .. stat.porazki
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. stat.remisy
            .. stat.remisy
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. stat.punkty
            .. stat.punkty
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. formatujMinuty(stat.minuty)
            .. formatujMinuty(
                stat.minuty
            )
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. stat.asysty
            .. stat.asysty
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. stat.zbiorki
            .. stat.zbiorki
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. stat.eval
            .. stat.eval
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. stat.plusminus
            .. stat.plusminus
         )
         )


Linia 1119: Linia 957:


     -- =====================================================
     -- =====================================================
     -- PODSUMOWANIE SEZONÓW
     -- PODSUMOWANIE WEDŁUG KLUBU
     -- =====================================================
     -- =====================================================


     table.insert(
     table.insert(
         wynik,
         wynik,
         "=== Podsumowanie sezonów ==="
         "=== Podsumowanie według klubu ==="
     )
     )


Linia 1137: Linia 975:
     )
     )


     table.insert(
     table.insert(wynik, "! Klub")
        wynik,
     table.insert(wynik, "! Występy")
        "! Sezon"
     table.insert(wynik, "! Zwycięstwa")
    )
     table.insert(wynik, "! Porażki")
 
     table.insert(wynik, "! Remisy")
     table.insert(
     table.insert(wynik, "! Punkty")
        wynik,
     table.insert(wynik, "! Minuty")
        "! Występy"
     table.insert(wynik, "! Asysty")
    )
     table.insert(wynik, "! Zbiórki")
 
     table.insert(wynik, "! EVAL")
     table.insert(
     table.insert(wynik, "! +/-")
        wynik,
        "! Zwycięstwa"
    )
 
     table.insert(
        wynik,
        "! Porażki"
    )
 
     table.insert(
        wynik,
        "! Remisy"
    )
 
     table.insert(
        wynik,
        "! Punkty"
    )
 
     table.insert(
        wynik,
        "! Minuty"
    )
 
     table.insert(
        wynik,
        "! Asysty"
     )
 
     table.insert(
        wynik,
        "! Zbiórki"
     )


    table.insert(
     for _, klub in ipairs(listaKlubow) do
        wynik,
        "! EVAL"
    )
 
    table.insert(
        wynik,
        "! +/-"
    )
 
     for _, sezon in ipairs(
        listaSezonow
    ) do


         local stat =
         local stat =
             sezony[sezon]
             kluby[klub]


         table.insert(
         table.insert(
Linia 1206: Linia 999:
         table.insert(
         table.insert(
             wynik,
             wynik,
             "| '''"
             "| '''" .. klub .. "'''"
            .. sezon
            .. "'''"
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. stat.wystepy
            .. stat.wystepy
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. stat.zwyciestwa
            .. stat.zwyciestwa
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. stat.porazki
            .. stat.porazki
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. stat.remisy
            .. stat.remisy
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. stat.punkty
            .. stat.punkty
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. formatujMinuty(stat.minuty)
            .. formatujMinuty(
                stat.minuty
            )
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. stat.asysty
            .. stat.asysty
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. stat.zbiorki
            .. stat.zbiorki
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. stat.eval
            .. stat.eval
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. stat.plusminus
            .. stat.plusminus
         )
         )


Linia 1304: Linia 1083:
     )
     )


     table.insert(
     table.insert(wynik, "! Nr")
        wynik,
     table.insert(wynik, "! Sezon")
        "! Nr"
     table.insert(wynik, "! Data")
    )
     table.insert(wynik, "! Miejsce")
 
     table.insert(wynik, "! Przeciwnik")
     table.insert(
     table.insert(wynik, "! Wynik")
        wynik,
     table.insert(wynik, "! Min.")
        "! Sezon"
     table.insert(wynik, "! Pkt")
    )
     table.insert(wynik, "! As.")
 
     table.insert(wynik, "! Zb.")
     table.insert(
     table.insert(wynik, "! EVAL")
        wynik,
     table.insert(wynik, "! +/-")
        "! Data"
     table.insert(wynik, "! Jubileusz")
    )
 
     table.insert(
        wynik,
        "! Miejsce"
    )
 
     table.insert(
        wynik,
        "! Przeciwnik"
    )
 
     table.insert(
        wynik,
        "! Wynik"
    )
 
     table.insert(
        wynik,
        "! Min."
    )
 
     table.insert(
        wynik,
        "! Pkt"
    )
 
     table.insert(
        wynik,
        "! As."
    )
 
     table.insert(
        wynik,
        "! Zb."
    )
 
     table.insert(
        wynik,
        "! EVAL"
    )
 
     table.insert(
        wynik,
        "! +/-"
    )
 
     table.insert(
        wynik,
        "! Jubileusz"
    )


     -- =====================================================
     -- =====================================================
Linia 1373: Linia 1101:
     -- =====================================================
     -- =====================================================


     for i, row in ipairs(
     for i, row in ipairs(rows) do
        rows
    ) do


         local data =
         local data =
Linia 1416: Linia 1142:
             row.plusminus or "0"
             row.plusminus or "0"


         -- -------------------------------------------------
         -- -----------------------------------------------
         -- DOM / WYJAZD
         -- DOM / WYJAZD
         -- -------------------------------------------------
         -- -----------------------------------------------


         local miejsce = ""
         local miejsce = ""
Linia 1424: Linia 1150:
         if druzyna == d1 then
         if druzyna == d1 then


             miejsce = "🏠 Dom"
             miejsce =
                "🏠 Dom"


         elseif druzyna == d2 then
         elseif druzyna == d2 then


             miejsce = "✈️ Wyjazd"
             miejsce =
                "✈️ Wyjazd"


         end
         end


         -- -------------------------------------------------
         -- -----------------------------------------------
         -- PRZECIWNIK
         -- PRZECIWNIK
         -- -------------------------------------------------
         -- -----------------------------------------------


         local przeciwnik = ""
         local przeciwnik = ""
Linia 1440: Linia 1168:
         if druzyna == d1 then
         if druzyna == d1 then


             przeciwnik = d2
             przeciwnik =
                d2


         elseif druzyna == d2 then
         elseif druzyna == d2 then


             przeciwnik = d1
             przeciwnik =
                d1


         else
         else


             przeciwnik = d1
             przeciwnik =
                d1


         end
         end


         -- -------------------------------------------------
         -- -----------------------------------------------
         -- LINK DO MECZU
         -- LINK DO MECZU
         -- -------------------------------------------------
         -- -----------------------------------------------


         local meczTekst =
         local meczTekst =
Linia 1470: Linia 1201:
         end
         end


         -- -------------------------------------------------
         -- -----------------------------------------------
         -- JUBILEUSZ
         -- JUBILEUSZ
         -- -------------------------------------------------
         -- -----------------------------------------------


         local jubileusz = ""
         local jubileusz = ""
Linia 1485: Linia 1216:
         end
         end


         -- -------------------------------------------------
         -- -----------------------------------------------
         -- WIERSZ
         -- WIERSZ
         -- -------------------------------------------------
         -- -----------------------------------------------


         table.insert(
         table.insert(
Linia 1496: Linia 1227:
         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. i
            .. i
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. sezon
            .. sezon
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. data
            .. data
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. miejsce
            .. miejsce
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. meczTekst
            .. meczTekst
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. wynikMeczu
            .. wynikMeczu
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. minutyFormat
            .. minutyFormat
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. pkt
            .. pkt
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. asysty
            .. asysty
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. zbiorki
            .. zbiorki
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. eval
            .. eval
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. plusminus
            .. plusminus
         )
         )


         table.insert(
         table.insert(
             wynik,
             wynik,
             "| "
             "| " .. jubileusz
            .. jubileusz
         )
         )


Linia 1582: Linia 1300:
         "|}"
         "|}"
     )
     )
    -- =====================================================
    -- ZWRÓCENIE WYNIKU
    -- =====================================================


     return table.concat(
     return table.concat(

Wersja z 09:24, 17 sie 2026

Dokumentacja dla tego modułu może zostać utworzona pod nazwą Moduł:HistoriaWystepow/opis

local p = {}

function p.main(frame)

    local zawodnik = frame.args.zawodnik

    if not zawodnik or zawodnik == "" then
        zawodnik = mw.title.getCurrentTitle().text
    end

    -- =====================================================
    -- BEZPIECZNE PRZYGOTOWANIE NAZWY ZAWODNIKA
    -- =====================================================

    local zawodnikSQL =
        mw.ustring.gsub(zawodnik, "'", "''")

    -- =====================================================
    -- POLA POBIERANE Z CARGO
    -- =====================================================

    local fields = table.concat({

        "UdzialZawodnika.mecz=mecz",
        "UdzialZawodnika.druzyna=druzyna",

        "UdzialZawodnika.minuty=minuty",
        "UdzialZawodnika.minuty_format=minuty_format",

        "UdzialZawodnika.gol=gol",
        "UdzialZawodnika.asysta=asysta",
        "UdzialZawodnika.zbiorka=zbiorka",

        "UdzialZawodnika.eval=eval",
        "UdzialZawodnika.plusminus=plusminus",

        "Mecze.data=data",
        "Mecze.sezon=sezon",

        "Mecze.druzyna1=druzyna1",
        "Mecze.druzyna2=druzyna2",

        "Mecze.wynik=wynik",
        "Mecze.strona_meczu=strona_meczu"

    }, ",")

    -- =====================================================
    -- ZAPYTANIE CARGO
    -- =====================================================

    local args = {

        join =
            "UdzialZawodnika.mecz=Mecze.id",

        where =
            "UdzialZawodnika.zawodnik='"
            .. zawodnikSQL
            .. "' AND UdzialZawodnika.minuty > 0",

        orderBy =
            "Mecze.data ASC",

        limit = 5000

    }

    local rows = mw.ext.cargo.query(
        "UdzialZawodnika,Mecze",
        fields,
        args
    )

    -- =====================================================
    -- BRAK DANYCH
    -- =====================================================

    if not rows or #rows == 0 then

        return "''Brak wprowadzonych występów w bazie.''"

    end

    -- =====================================================
    -- NOWE PODSUMOWANIE
    -- =====================================================

    local function nowePodsumowanie()

        return {

            wystepy = 0,

            zwyciestwa = 0,
            porazki = 0,
            remisy = 0,

            punkty = 0,
            minuty = 0,

            asysty = 0,
            zbiorki = 0,

            eval = 0,
            plusminus = 0

        }

    end

    -- =====================================================
    -- PODSUMOWANIA
    -- =====================================================

    local suma =
        nowePodsumowanie()

    local dom =
        nowePodsumowanie()

    local wyjazd =
        nowePodsumowanie()

    -- sezony
    local sezony = {}

    -- kluby
    local kluby = {}

    -- =====================================================
    -- OKREŚLENIE WYNIKU MECZU
    -- =====================================================

    local function okreslWynik(row)

        local d1 =
            row.druzyna1 or ""

        local d2 =
            row.druzyna2 or ""

        local druzyna =
            row.druzyna or ""

        local wynikMeczu =
            row.wynik or ""

        local g1, g2 =
            wynikMeczu:match(
                "(%d+)%s*:%s*(%d+)"
            )

        if not g1 or not g2 then
            return nil
        end

        g1 = tonumber(g1)
        g2 = tonumber(g2)

        if druzyna == d1 then

            if g1 > g2 then
                return "W"

            elseif g1 < g2 then
                return "P"

            else
                return "R"
            end

        elseif druzyna == d2 then

            if g2 > g1 then
                return "W"

            elseif g2 < g1 then
                return "P"

            else
                return "R"
            end

        end

        return nil

    end

    -- =====================================================
    -- DODANIE MECZU DO PODSUMOWANIA
    -- =====================================================

    local function dodajDoPodsumowania(
        stat,
        row
    )

        stat.wystepy =
            stat.wystepy + 1

        stat.punkty =
            stat.punkty
            + tonumber(row.gol or 0)

        stat.minuty =
            stat.minuty
            + tonumber(row.minuty or 0)

        stat.asysty =
            stat.asysty
            + tonumber(row.asysta or 0)

        stat.zbiorki =
            stat.zbiorki
            + tonumber(row.zbiorka or 0)

        stat.eval =
            stat.eval
            + tonumber(row.eval or 0)

        stat.plusminus =
            stat.plusminus
            + tonumber(row.plusminus or 0)

        local wynik =
            okreslWynik(row)

        if wynik == "W" then

            stat.zwyciestwa =
                stat.zwyciestwa + 1

        elseif wynik == "P" then

            stat.porazki =
                stat.porazki + 1

        elseif wynik == "R" then

            stat.remisy =
                stat.remisy + 1

        end

    end

    -- =====================================================
    -- PRZEJŚCIE PRZEZ WSZYSTKIE MECZE
    -- =====================================================

    for _, row in ipairs(rows) do

        -- -----------------------------------------------
        -- WSZYSTKIE
        -- -----------------------------------------------

        dodajDoPodsumowania(
            suma,
            row
        )

        -- -----------------------------------------------
        -- DOM / WYJAZD
        -- -----------------------------------------------

        local d1 =
            row.druzyna1 or ""

        local d2 =
            row.druzyna2 or ""

        local druzyna =
            row.druzyna or ""

        if druzyna == d1 then

            dodajDoPodsumowania(
                dom,
                row
            )

        elseif druzyna == d2 then

            dodajDoPodsumowania(
                wyjazd,
                row
            )

        end

        -- -----------------------------------------------
        -- SEZON
        -- -----------------------------------------------

        local sezon =
            row.sezon or ""

        if sezon == "" then
            sezon = "Brak sezonu"
        end

        if not sezony[sezon] then

            sezony[sezon] =
                nowePodsumowanie()

        end

        dodajDoPodsumowania(
            sezony[sezon],
            row
        )

        -- -----------------------------------------------
        -- KLUB
        -- -----------------------------------------------

        if druzyna == "" then
            druzyna = "Brak klubu"
        end

        if not kluby[druzyna] then

            kluby[druzyna] =
                nowePodsumowanie()

        end

        dodajDoPodsumowania(
            kluby[druzyna],
            row
        )

    end

    -- =====================================================
    -- FORMATOWANIE MINUT
    -- =====================================================

    local function formatujMinuty(minuty)

        local godziny =
            math.floor(minuty / 60)

        local min =
            minuty % 60

        return string.format(
            "%d:%02d",
            godziny,
            min
        )

    end

    -- =====================================================
    -- SORTOWANIE SEZONÓW
    -- =====================================================

    local listaSezonow = {}

    for sezon, _ in pairs(sezony) do

        table.insert(
            listaSezonow,
            sezon
        )

    end

    table.sort(
        listaSezonow,
        function(a, b)

            return a > b

        end
    )

    -- =====================================================
    -- SORTOWANIE KLUBÓW
    -- =====================================================

    local listaKlubow = {}

    for klub, _ in pairs(kluby) do

        table.insert(
            listaKlubow,
            klub
        )

    end

    table.sort(
        listaKlubow
    )

    -- =====================================================
    -- FUNKCJA: CZY JEST MECZ DOMOWY?
    -- =====================================================

    local function czyDom(row)

        local druzyna =
            row.druzyna or ""

        local d1 =
            row.druzyna1 or ""

        return druzyna == d1

    end

    -- =====================================================
    -- FUNKCJA OPISUJĄCA MECZ
    --
    -- WAŻNE:
    -- ZAWSZE GOSPODARZ – GOŚĆ
    -- =====================================================

    local function rekordMecz(row)

        local d1 =
            row.druzyna1 or ""

        local d2 =
            row.druzyna2 or ""

        local data =
            row.data or ""

        local wynikMeczu =
            row.wynik or ""

        local strona =
            row.strona_meczu or ""

        -- -----------------------------------------------
        -- FAKTYCZNY ZAPIS MECZU
        -- -----------------------------------------------

        local meczTekst =
            d1
            .. " – "
            .. d2

        -- -----------------------------------------------
        -- LINK DO STRONY MECZU
        -- -----------------------------------------------

        if strona ~= "" then

            meczTekst =
                "[["
                .. strona
                .. "|"
                .. d1
                .. " – "
                .. d2
                .. "]]"

        end

        -- -----------------------------------------------
        -- DATA
        -- -----------------------------------------------

        if data ~= "" then

            meczTekst =
                meczTekst
                .. " ("
                .. data
                .. ")"

        end

        -- -----------------------------------------------
        -- WYNIK
        -- -----------------------------------------------

        if wynikMeczu ~= "" then

            meczTekst =
                meczTekst
                .. " "
                .. wynikMeczu

        end

        return meczTekst

    end

    -- =====================================================
    -- REKORDY
    -- =====================================================

    local rekordPunkty = -1
    local rekordMinuty = -1
    local rekordAsysty = -1
    local rekordZbiorki = -1

    local meczePunkty = {}
    local meczeMinuty = {}
    local meczeAsysty = {}
    local meczeZbiorki = {}

    -- =====================================================
    -- WYSZUKIWANIE REKORDÓW
    -- =====================================================

    for _, row in ipairs(rows) do

        local punkty =
            tonumber(row.gol or 0)

        local minuty =
            tonumber(row.minuty or 0)

        local asysty =
            tonumber(row.asysta or 0)

        local zbiorki =
            tonumber(row.zbiorka or 0)

        -- -----------------------------------------------
        -- PUNKTY
        -- -----------------------------------------------

        if punkty > rekordPunkty then

            rekordPunkty = punkty

            meczePunkty = { row }

        elseif punkty == rekordPunkty then

            table.insert(
                meczePunkty,
                row
            )

        end

        -- -----------------------------------------------
        -- MINUTY
        -- -----------------------------------------------

        if minuty > rekordMinuty then

            rekordMinuty = minuty

            meczeMinuty = { row }

        elseif minuty == rekordMinuty then

            table.insert(
                meczeMinuty,
                row
            )

        end

        -- -----------------------------------------------
        -- ASYSTY
        -- -----------------------------------------------

        if asysty > rekordAsysty then

            rekordAsysty = asysty

            meczeAsysty = { row }

        elseif asysty == rekordAsysty then

            table.insert(
                meczeAsysty,
                row
            )

        end

        -- -----------------------------------------------
        -- ZBIÓRKI
        -- -----------------------------------------------

        if zbiorki > rekordZbiorki then

            rekordZbiorki = zbiorki

            meczeZbiorki = { row }

        elseif zbiorki == rekordZbiorki then

            table.insert(
                meczeZbiorki,
                row
            )

        end

    end

    -- =====================================================
    -- LISTA MECZÓW W REKORDZIE
    -- =====================================================

    local function listaRekordow(lista)

        local wynikRekordu = {}

        for _, row in ipairs(lista) do

            table.insert(
                wynikRekordu,
                rekordMecz(row)
            )

        end

        return table.concat(
            wynikRekordu,
            "<br>"
        )

    end

    -- =====================================================
    -- WYNIK
    -- =====================================================

    local wynik = {}

    -- =====================================================
    -- HISTORIA
    -- =====================================================

    table.insert(
        wynik,
        "== Historia występów =="
    )

    table.insert(
        wynik,
        ""
    )

    -- =====================================================
    -- PODSUMOWANIE WSZYSTKICH / DOM / WYJAZD
    -- =====================================================

    table.insert(
        wynik,
        "=== Podsumowanie wszystkich spotkań ==="
    )

    table.insert(
        wynik,
        ""
    )

    table.insert(
        wynik,
        '{| class="wikitable" style="width:100%; text-align:center;"'
    )

    table.insert(
        wynik,
        "! "
    )

    table.insert(
        wynik,
        "! Wszystkie spotkania"
    )

    table.insert(
        wynik,
        "! 🏠 Mecze domowe"
    )

    table.insert(
        wynik,
        "! ✈️ Mecze wyjazdowe"
    )

    -- WYSTĘPY

    table.insert(wynik, "|-")
    table.insert(wynik, "! Występy")
    table.insert(wynik, "| '''" .. suma.wystepy .. "'''")
    table.insert(wynik, "| '''" .. dom.wystepy .. "'''")
    table.insert(wynik, "| '''" .. wyjazd.wystepy .. "'''")

    -- ZWYCIĘSTWA

    table.insert(wynik, "|-")
    table.insert(wynik, "! Zwycięstwa")
    table.insert(wynik, "| '''" .. suma.zwyciestwa .. "'''")
    table.insert(wynik, "| '''" .. dom.zwyciestwa .. "'''")
    table.insert(wynik, "| '''" .. wyjazd.zwyciestwa .. "'''")

    -- PORAŻKI

    table.insert(wynik, "|-")
    table.insert(wynik, "! Porażki")
    table.insert(wynik, "| '''" .. suma.porazki .. "'''")
    table.insert(wynik, "| '''" .. dom.porazki .. "'''")
    table.insert(wynik, "| '''" .. wyjazd.porazki .. "'''")

    -- REMISY

    table.insert(wynik, "|-")
    table.insert(wynik, "! Remisy")
    table.insert(wynik, "| '''" .. suma.remisy .. "'''")
    table.insert(wynik, "| '''" .. dom.remisy .. "'''")
    table.insert(wynik, "| '''" .. wyjazd.remisy .. "'''")

    -- PUNKTY

    table.insert(wynik, "|-")
    table.insert(wynik, "! Punkty")
    table.insert(wynik, "| '''" .. suma.punkty .. "'''")
    table.insert(wynik, "| '''" .. dom.punkty .. "'''")
    table.insert(wynik, "| '''" .. wyjazd.punkty .. "'''")

    -- MINUTY

    table.insert(wynik, "|-")
    table.insert(wynik, "! Minuty")
    table.insert(wynik, "| '''" .. formatujMinuty(suma.minuty) .. "'''")
    table.insert(wynik, "| '''" .. formatujMinuty(dom.minuty) .. "'''")
    table.insert(wynik, "| '''" .. formatujMinuty(wyjazd.minuty) .. "'''")

    -- ASYSTY

    table.insert(wynik, "|-")
    table.insert(wynik, "! Asysty")
    table.insert(wynik, "| '''" .. suma.asysty .. "'''")
    table.insert(wynik, "| '''" .. dom.asysty .. "'''")
    table.insert(wynik, "| '''" .. wyjazd.asysty .. "'''")

    -- ZBIÓRKI

    table.insert(wynik, "|-")
    table.insert(wynik, "! Zbiórki")
    table.insert(wynik, "| '''" .. suma.zbiorki .. "'''")
    table.insert(wynik, "| '''" .. dom.zbiorki .. "'''")
    table.insert(wynik, "| '''" .. wyjazd.zbiorki .. "'''")

    -- EVAL

    table.insert(wynik, "|-")
    table.insert(wynik, "! EVAL")
    table.insert(wynik, "| '''" .. suma.eval .. "'''")
    table.insert(wynik, "| '''" .. dom.eval .. "'''")
    table.insert(wynik, "| '''" .. wyjazd.eval .. "'''")

    -- PLUS/MINUS

    table.insert(wynik, "|-")
    table.insert(wynik, "! +/-")
    table.insert(wynik, "| '''" .. suma.plusminus .. "'''")
    table.insert(wynik, "| '''" .. dom.plusminus .. "'''")
    table.insert(wynik, "| '''" .. wyjazd.plusminus .. "'''")

    table.insert(
        wynik,
        "|}"
    )

    table.insert(
        wynik,
        ""
    )

    -- =====================================================
    -- REKORDY ZAWODNIKA
    -- =====================================================

    table.insert(
        wynik,
        "=== Najlepsze występy ==="
    )

    table.insert(
        wynik,
        ""
    )

    table.insert(
        wynik,
        '{| class="wikitable" style="width:100%;"'
    )

    table.insert(
        wynik,
        "! Rekord"
    )

    table.insert(
        wynik,
        "! Wynik"
    )

    table.insert(
        wynik,
        "! Mecz / mecze"
    )

    -- PUNKTY

    table.insert(wynik, "|-")
    table.insert(wynik, "! 🏀 Najwięcej punktów")
    table.insert(wynik, "| '''" .. rekordPunkty .. "'''")
    table.insert(wynik, "| " .. listaRekordow(meczePunkty))

    -- MINUTY

    table.insert(wynik, "|-")
    table.insert(wynik, "! ⏱ Najwięcej minut")
    table.insert(wynik, "| '''" .. formatujMinuty(rekordMinuty) .. "'''")
    table.insert(wynik, "| " .. listaRekordow(meczeMinuty))

    -- ASYSTY

    table.insert(wynik, "|-")
    table.insert(wynik, "! 🎯 Najwięcej asyst")
    table.insert(wynik, "| '''" .. rekordAsysty .. "'''")
    table.insert(wynik, "| " .. listaRekordow(meczeAsysty))

    -- ZBIÓRKI

    table.insert(wynik, "|-")
    table.insert(wynik, "! 🏀 Najwięcej zbiórek")
    table.insert(wynik, "| '''" .. rekordZbiorki .. "'''")
    table.insert(wynik, "| " .. listaRekordow(meczeZbiorki))

    table.insert(
        wynik,
        "|}"
    )

    table.insert(
        wynik,
        ""
    )

    -- =====================================================
    -- PODSUMOWANIE SEZONÓW
    -- =====================================================

    table.insert(
        wynik,
        "=== Podsumowanie sezonów ==="
    )

    table.insert(
        wynik,
        ""
    )

    table.insert(
        wynik,
        '{| class="wikitable sortable" style="width:100%; text-align:center;"'
    )

    table.insert(wynik, "! Sezon")
    table.insert(wynik, "! Występy")
    table.insert(wynik, "! Zwycięstwa")
    table.insert(wynik, "! Porażki")
    table.insert(wynik, "! Remisy")
    table.insert(wynik, "! Punkty")
    table.insert(wynik, "! Minuty")
    table.insert(wynik, "! Asysty")
    table.insert(wynik, "! Zbiórki")
    table.insert(wynik, "! EVAL")
    table.insert(wynik, "! +/-")

    for _, sezon in ipairs(listaSezonow) do

        local stat =
            sezony[sezon]

        table.insert(wynik, "|-")

        table.insert(
            wynik,
            "| '''" .. sezon .. "'''"
        )

        table.insert(
            wynik,
            "| " .. stat.wystepy
        )

        table.insert(
            wynik,
            "| " .. stat.zwyciestwa
        )

        table.insert(
            wynik,
            "| " .. stat.porazki
        )

        table.insert(
            wynik,
            "| " .. stat.remisy
        )

        table.insert(
            wynik,
            "| " .. stat.punkty
        )

        table.insert(
            wynik,
            "| " .. formatujMinuty(stat.minuty)
        )

        table.insert(
            wynik,
            "| " .. stat.asysty
        )

        table.insert(
            wynik,
            "| " .. stat.zbiorki
        )

        table.insert(
            wynik,
            "| " .. stat.eval
        )

        table.insert(
            wynik,
            "| " .. stat.plusminus
        )

    end

    table.insert(
        wynik,
        "|}"
    )

    table.insert(
        wynik,
        ""
    )

    -- =====================================================
    -- PODSUMOWANIE WEDŁUG KLUBU
    -- =====================================================

    table.insert(
        wynik,
        "=== Podsumowanie według klubu ==="
    )

    table.insert(
        wynik,
        ""
    )

    table.insert(
        wynik,
        '{| class="wikitable sortable" style="width:100%; text-align:center;"'
    )

    table.insert(wynik, "! Klub")
    table.insert(wynik, "! Występy")
    table.insert(wynik, "! Zwycięstwa")
    table.insert(wynik, "! Porażki")
    table.insert(wynik, "! Remisy")
    table.insert(wynik, "! Punkty")
    table.insert(wynik, "! Minuty")
    table.insert(wynik, "! Asysty")
    table.insert(wynik, "! Zbiórki")
    table.insert(wynik, "! EVAL")
    table.insert(wynik, "! +/-")

    for _, klub in ipairs(listaKlubow) do

        local stat =
            kluby[klub]

        table.insert(
            wynik,
            "|-"
        )

        table.insert(
            wynik,
            "| '''" .. klub .. "'''"
        )

        table.insert(
            wynik,
            "| " .. stat.wystepy
        )

        table.insert(
            wynik,
            "| " .. stat.zwyciestwa
        )

        table.insert(
            wynik,
            "| " .. stat.porazki
        )

        table.insert(
            wynik,
            "| " .. stat.remisy
        )

        table.insert(
            wynik,
            "| " .. stat.punkty
        )

        table.insert(
            wynik,
            "| " .. formatujMinuty(stat.minuty)
        )

        table.insert(
            wynik,
            "| " .. stat.asysty
        )

        table.insert(
            wynik,
            "| " .. stat.zbiorki
        )

        table.insert(
            wynik,
            "| " .. stat.eval
        )

        table.insert(
            wynik,
            "| " .. stat.plusminus
        )

    end

    table.insert(
        wynik,
        "|}"
    )

    table.insert(
        wynik,
        ""
    )

    -- =====================================================
    -- TABELA WSZYSTKICH WYSTĘPÓW
    -- =====================================================

    table.insert(
        wynik,
        "=== Mecze ==="
    )

    table.insert(
        wynik,
        ""
    )

    table.insert(
        wynik,
        '{| class="wikitable sortable" style="width:100%;"'
    )

    table.insert(wynik, "! Nr")
    table.insert(wynik, "! Sezon")
    table.insert(wynik, "! Data")
    table.insert(wynik, "! Miejsce")
    table.insert(wynik, "! Przeciwnik")
    table.insert(wynik, "! Wynik")
    table.insert(wynik, "! Min.")
    table.insert(wynik, "! Pkt")
    table.insert(wynik, "! As.")
    table.insert(wynik, "! Zb.")
    table.insert(wynik, "! EVAL")
    table.insert(wynik, "! +/-")
    table.insert(wynik, "! Jubileusz")

    -- =====================================================
    -- POSZCZEGÓLNE MECZE
    -- =====================================================

    for i, row in ipairs(rows) do

        local data =
            row.data or ""

        local sezon =
            row.sezon or ""

        local d1 =
            row.druzyna1 or ""

        local d2 =
            row.druzyna2 or ""

        local druzyna =
            row.druzyna or ""

        local wynikMeczu =
            row.wynik or ""

        local strona =
            row.strona_meczu or ""

        local minutyFormat =
            row.minuty_format or ""

        local pkt =
            row.gol or "0"

        local asysty =
            row.asysta or "0"

        local zbiorki =
            row.zbiorka or "0"

        local eval =
            row.eval or "0"

        local plusminus =
            row.plusminus or "0"

        -- -----------------------------------------------
        -- DOM / WYJAZD
        -- -----------------------------------------------

        local miejsce = ""

        if druzyna == d1 then

            miejsce =
                "🏠 Dom"

        elseif druzyna == d2 then

            miejsce =
                "✈️ Wyjazd"

        end

        -- -----------------------------------------------
        -- PRZECIWNIK
        -- -----------------------------------------------

        local przeciwnik = ""

        if druzyna == d1 then

            przeciwnik =
                d2

        elseif druzyna == d2 then

            przeciwnik =
                d1

        else

            przeciwnik =
                d1

        end

        -- -----------------------------------------------
        -- LINK DO MECZU
        -- -----------------------------------------------

        local meczTekst =
            przeciwnik

        if strona ~= "" then

            meczTekst =
                "[["
                .. strona
                .. "|"
                .. przeciwnik
                .. "]]"

        end

        -- -----------------------------------------------
        -- JUBILEUSZ
        -- -----------------------------------------------

        local jubileusz = ""

        if i % 50 == 0 then

            jubileusz =
                "'''🏆 "
                .. i
                .. ". występ'''"

        end

        -- -----------------------------------------------
        -- WIERSZ
        -- -----------------------------------------------

        table.insert(
            wynik,
            "|-"
        )

        table.insert(
            wynik,
            "| " .. i
        )

        table.insert(
            wynik,
            "| " .. sezon
        )

        table.insert(
            wynik,
            "| " .. data
        )

        table.insert(
            wynik,
            "| " .. miejsce
        )

        table.insert(
            wynik,
            "| " .. meczTekst
        )

        table.insert(
            wynik,
            "| " .. wynikMeczu
        )

        table.insert(
            wynik,
            "| " .. minutyFormat
        )

        table.insert(
            wynik,
            "| " .. pkt
        )

        table.insert(
            wynik,
            "| " .. asysty
        )

        table.insert(
            wynik,
            "| " .. zbiorki
        )

        table.insert(
            wynik,
            "| " .. eval
        )

        table.insert(
            wynik,
            "| " .. plusminus
        )

        table.insert(
            wynik,
            "| " .. jubileusz
        )

    end

    -- =====================================================
    -- KONIEC TABELI
    -- =====================================================

    table.insert(
        wynik,
        "|}"
    )

    -- =====================================================
    -- ZWRÓCENIE WYNIKU
    -- =====================================================

    return table.concat(
        wynik,
        "\n"
    )

end

return p