Jump to content

User:Xover/sandbox/Module:WikiProject quality summary

From Wikipedia, the free encyclopedia

-- This module's function lookup table, used by the calling context local p = {}

function p.qstats(frame)

 local title = mw.title.getCurrentTitle()
 local project = string.sub(title.rootText, 13, -1)
 local cSuffix = "-Class " .. project .. " articles"
 local qFA    = mw.site.stats.pagesInCategory("FA"    .. cSuffix, "pages")
 local qGA    = mw.site.stats.pagesInCategory("GA"    .. cSuffix, "pages")
 local qA     = mw.site.stats.pagesInCategory("A"     .. cSuffix, "pages")
 local qB     = mw.site.stats.pagesInCategory("B"     .. cSuffix, "pages")
 local qC     = mw.site.stats.pagesInCategory("C"     .. cSuffix, "pages")
 local qStart = mw.site.stats.pagesInCategory("Start" .. cSuffix, "pages")
 local qStub  = mw.site.stats.pagesInCategory("Stub"  .. cSuffix, "pages")
 local qList  = mw.site.stats.pagesInCategory("List"  .. cSuffix, "pages")
 local total = qFA + qGA + qA + qB + qC + qStart + qStub + qList
 local pnFA = total / qFA
 local ppFA = (100 / total) * qFA
 local pnGA = total / qGA
 local ppGA = (100 / total) * qGA
 local pnFAGA = total / (qFA + qGA)
 local ppFAGA = (100 / total) * (qFA + qGA)
 local format = [[There are %0d articles within the scope of the Shakespeare project. Currently the project has %0d Featured articles, or 1 out of every %0d articles in the project (%1d%%). It also has %0d Good articles: 1 out of every %0d articles (%1d%%). Thus, one in %0d articles in the project is rated GA or higher (%1d%%).]]
 return mw.ustring.format(format, total, qFA, pnFA, ppFA, qGA, pnGA, ppGA, pnFAGA, ppFAGA)

end

return p