Jump to content

Module:PopularArticles: Difference between revisions

From Iskomunidad
No edit summary
No edit summary
Line 2: Line 2:


function p.main(frame)
function p.main(frame)
     local category = frame.args.category or "Theses"
     local category = frame.args.category or "Theses"


     local count = mw.site.stats.pagesInCategory(
     local data = mw.ext.analytics.getViewsData({
         category,
         page = "Category:" .. category
         "pages"
    })
     )
 
    if not data then
        return "NO DATA RETURNED"
    end
 
    local output = {
        "Analytics test for Category:" .. category
    }
 
    for key, value in pairs(data) do
         table.insert(
            output,
            tostring(key) .. " = " .. tostring(value)
        )
     end


     return "Pages in Category:" .. category .. " = " .. tostring(count)
     return table.concat(output, "<br>")
end
end


return p
return p

Revision as of 06:22, 2 October 2026

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

local p = {}

function p.main(frame)

    local category = frame.args.category or "Theses"

    local data = mw.ext.analytics.getViewsData({
        page = "Category:" .. category
    })

    if not data then
        return "NO DATA RETURNED"
    end

    local output = {
        "Analytics test for Category:" .. category
    }

    for key, value in pairs(data) do
        table.insert(
            output,
            tostring(key) .. " = " .. tostring(value)
        )
    end

    return table.concat(output, "<br>")
end

return p