打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
登录后可编辑和发表评论。

Module:VOCALOID殿堂曲/Stats

来自Vocawiki

此模块的文档可以在Module:VOCALOID殿堂曲/Stats/doc创建

local module = {}

local getArgs = require('Module:Arguments').getArgs

function module.count(page)
	local title = mw.title.new(page)
	local content = title:getContent()
	if not content then
		return
	end

	local count = 0
	for i in string.gmatch(content, "[Tt]emple[ _]Song") do
		count = count + 1
	end
	for i in string.gmatch(content, "[Ss]ong[ _]Honor") do
		count = count + 1
	end

	return count
end

function module.main(frame)
	local args = getArgs(frame)
	local prefix = args['prefix']
	local startYear = args['startYear']
	local includeSelf = args['includeSelf']
	local i = startYear
	local total = 0
	
	if includeSelf then
		local count = module.count(prefix)
		if count then
			total = count
		end
	end
	
	local thisYear = os.date("%Y")
	for i = startYear, thisYear do
		repeat
			local count = module.count(string.format("%s/%d年投稿", prefix, i))
			if not count then break end
			total = total + count
		until true
	end
	return tostring(total)
end

return module