মডিউল:নির্ঘণ্টের অগ্রগতি

{{নির্ঘণ্টের অগ্রগতি দণ্ড}}{{নির্ঘণ্টের অগ্রগতি পাই চার্ট}}-এর জন্য।


--[=[
This is a module to extract data from the ProofreadPage Lua API
and feed it into a {{progress bar}}
]=]

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

local p = {} --p stands for package
local proofreadPage = require('mw.ext.proofreadPage')
local yesno = require('Module:Yesno')

--[=[
Map ProofradPage Lua index progress to {{Progress bar}} and
return the expanded template
]=]
function progressStatsToBar( frame, index, existing_only, height )
	
	local total
	if existing_only then
		total = index.existingPages
	else
		total = index.pageCount
	end
	
	return frame:expandTemplate{
		title = 'অগ্রগতি দণ্ড',
		args = {
			total = total,
			notext = index:pagesWithLevel( 0 ),
			['not proofread'] = index:pagesWithLevel( 1 ),
			problematic = index:pagesWithLevel( 2 ),
			proofread = index:pagesWithLevel( 3 ),
			validated = index:pagesWithLevel( 4 ),
			height = height
		}
    }
end

function p.bar( frame )

	local args = getArgs(frame)
	local idx = args[ 1 ]
		:gsub( '^Index:', '' )
	local existing_only = yesno(args.existing_only or 'no')
	local height = args.height

	local index = proofreadPage.newIndex( idx )
	if not index then
		return nil
	end
	
	return progressStatsToBar( frame, index, existing_only, height )
end

--[=[
Map ProofradPage Lua index progress to {{progress pie chart}} and
return the expanded template
]=]
function progressStatsToPie( frame, index, existing_only, no_legend )
	
	local total
	if existing_only then
		total = index.existingPages
	else
		total = index.pageCount
	end
	
	return frame:expandTemplate{
		title = 'Progress pie chart',
		args = {
			total = total,
			notext = index:pagesWithLevel( 0 ),
			['not proofread'] = index:pagesWithLevel( 1 ),
			problematic = index:pagesWithLevel( 2 ),
			proofread = index:pagesWithLevel( 3 ),
			validated = index:pagesWithLevel( 4 ),
			existing_only = existing_only,
			no_legend = no_legend
		}
    }
end

function p.pie( frame )

	local args = getArgs(frame)
	local idx = args[ 1 ]
		:gsub( '^Index:', '' )
	local existing_only = yesno(args.existing_only or 'no')
	local no_legend = yesno(args.no_legend or 'no')

	local index = proofreadPage.newIndex( idx )
	if not index then
		return nil
	end
	
	return progressStatsToPie( frame, index, existing_only, no_legend )
end

return p