Module:Wiktionary logo statistics
This module keeps the table at Wiktionary/logo#Logo use statistics up to date based on the statistics at Wiktionary/Table, so we know the relative prominence of each of Wiktionary's logos.
-- For [[Wiktionary/logo#Logo use statistics]]
local p = {}
local projectStats = require("Module:Project statistics")
local dataByWiki = require("Module:Project portal/wikis")
-- A breakdown of wikis by logo usage.
p.knownLogos = {
tiles = {
desc = "Tile design by Smurrayinchester",
file = "Wiktionary-logo.svg",
wikis = {},
},
text = {
desc = "Textual design by Brion Vibber",
file = "Wiktionary-logo-en.svg",
wikis = {},
},
book = {
desc = "Book design by AAEngelman",
file = "Wiktionary book logo.png",
wikis = {},
},
galicia = {
desc = "Galician coat of arms",
file = "Wiktionary-logo-gl.png",
wikis = {},
},
}
-- Default logo for new wikis.
local defaultLogo = "tiles"
-- Date of the last comprehensive survey of logo usage.
local logoDate = "2015-07-22"
local lang = mw.getContentLanguage()
function p.getStatistics()
local statistics = projectStats.getStatistics("wiktionary")
local statsByWiki = statistics.wikis
local totalWikis = 0
local totalEntries = 0
local totalActiveUsers = 0
for wiki, stats in pairs(statsByWiki) do
local data = dataByWiki[wiki] and dataByWiki[wiki].wiktionary
local logo = p.knownLogos[(data and data.logo) or defaultLogo]
table.insert(logo.wikis, wiki)
logo.numEntries = (logo.numEntries or 0) + stats.articles
logo.numActiveUsers = (logo.numActiveUsers or 0) + stats.activeUsers
totalEntries = totalEntries + stats.articles
totalActiveUsers = totalActiveUsers + stats.activeUsers
totalWikis = totalWikis + 1
end
for name, logo in pairs(p.knownLogos) do
table.sort(logo.wikis)
end
return table.concat(statistics.date, "-"), {
wikis = totalWikis,
entries = totalEntries,
activeUsers = totalActiveUsers,
}
end
function p.main(frame)
local updatedDate, totals = p.getStatistics()
local logos = {}
for name, logo in pairs(p.knownLogos) do
table.insert(logos, logo)
end
table.sort(logos, function (left, right)
return #left.wikis > #right.wikis
end)
local items = {}
for i, logo in ipairs(logos) do
local wikis = {}
for i, wiki in ipairs(logo.wikis) do
table.insert(wikis, string.format("[[wikt:%s:|%s:]]", wiki, wiki))
end
wikis = table.concat(wikis, ", ")
local item = mw.ustring.format("; [[:File:%s|%s]] — %s %s (%.2f%%), %s %s (%.2f%%), %s %s (%.2f%%)\n: %s",
logo.file, logo.desc, lang:formatNum(#logo.wikis), lang:plural(#logo.wikis, "wiki", "wikis"),
#logo.wikis / totals.wikis * 100, lang:formatNum(logo.numEntries),
lang:plural(logo.numEntries, "entry", "entries"), logo.numEntries / totals.entries * 100,
lang:formatNum(logo.numActiveUsers), lang:plural(logo.numActiveUsers, "active user", "active users"),
logo.numActiveUsers / totals.activeUsers * 100, wikis)
table.insert(items, item)
end
local statsTitle = projectStats.statsTitleForProject("wiktionary")
return mw.ustring.format("[[Module:Wiktionary logo statistics|Logo usage]] data is current as of %s. Wiki statistics are based on [[%s]] (current as of %s).\n\n%s",
logoDate, statsTitle.fullText, updatedDate,
table.concat(items, "\n\n"))
end
return p