ਸਮੱਗਰੀ 'ਤੇ ਜਾਓ

ਮੌਡਿਊਲ:Index progress

ਵਿਕੀਸਰੋਤ ਤੋਂ

Logic for {{index progress bar}} and {{index progress pie chart}}


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

local getArgs = require('Module:Arguments').getArgs
local proofreadPage = require('mw.ext.proofreadPage')
local yesno = require('Module:Yesno')
local progress_bar = require('Module:Progress bar')._progress_bar
local progress_pie_chart = require('Module:Progress pie chart')._progress_pie_chart

--[=[
Map ProofreadPage Lua index progress to progress_bar
]=]

function p.bar(frame)
	local args = getArgs(frame)
	
	local idx = args[1]
		:gsub('^Index:', '')
	
	local index = proofreadPage.newIndex(idx)
	if not index then
		return nil
	end
	
	local barArgs = {
		['total'] = index.pageCount,
		['notext'] = index:pagesWithLevel(0),
		['not_proofread'] = index:pagesWithLevel(1),
		['problematic'] = index:pagesWithLevel(2),
		['proofread'] = index:pagesWithLevel(3),
		['validated'] = index:pagesWithLevel(4),
		['height'] = args.height,
		['width'] = args.width,
		['existing_only'] = args.existing_only
	}
	return progress_bar(barArgs)
end

--[=[
Map ProofreadPage Lua index progress to progress_pie_chart and return the expanded template
]=]

function p.pie(frame)
	local args = getArgs(frame)
	
	local idx = args[1]
		:gsub('^Index:', '')

	local index = proofreadPage.newIndex(idx)
	if not index then
		return nil
	end
	
	local total = index.pageCount
	
	pieArgs = {
		['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'] = args.existing_only,
		['no_legend'] = args.no_legend,
		['size'] = args.size
	}
	return progress_pie_chart(pieArgs)
end

return p