Module:Gerrit dashboard/Community Tech

Module documentation
local dashboard = require( 'Module:Gerrit dashboard' )
local link_to_dashboard = dashboard._link_to_dashboard

local team_members = {}
local projects = {}

local dashboard_def = {}

local add_team_member = function ( member, name )
	table.insert( team_members, { member, name } )
end

local add_team_members_to_constraints = function ( constrs )
	for _, tm in ipairs( team_members ) do
		table.insert( constrs, { 'owner', tm[2] } )
	end
end

local add_projects_to_constraints = function ( constrs )
	for _, p in ipairs( projects ) do
		table.insert( constrs, { 'project', p } )
	end
end

local add_ext = function ( ext, limit )
	local proj = 'mediawiki/extensions/' .. ext
	
	limit = limit or 10

	table.insert( dashboard_def, { ext, {
		{ 'project', proj },
		{ 'status', 'open' },
		{ 'limit', limit }
	} } )
	
	table.insert( projects, proj )
end

local add_proj = function ( proj, name, limit )
	local owner_constrs = {}
	limit = limit or 10

	add_team_members_to_constraints( owner_constrs )

	table.insert( dashboard_def, { name, {
		{ 'project', proj },
		{ 'status', 'open' },
		{ 'OR', owner_constrs },
		{ 'limit', limit }
	} } )
	
	table.insert( projects, proj )
end

local get_all_possible_constraints = function ()
	local constrs = {}
	add_team_members_to_constraints( constrs )
	add_projects_to_constraints( constrs )
	return constrs
end

add_team_member( 'samtar', 'TheresNoTime' )
--add_team_member( 'musikanimal', 'MusikAnimal' )

add_ext( 'CommunityRequests' )
add_ext( 'CodeMirror' )
add_ext( 'Phonos' )
add_proj( 'mediawiki/core', 'Core' )
add_proj( 'operations/mediawiki-config', 'Config' )

table.insert( dashboard_def, { 'Recently merged', {
	{ 'status', 'merged' },
	{ 'NOT', { 'owner', 'L10n-bot' } },
	{ 'OR', get_all_possible_constraints() },
	{ 'limit', 20 }
} } )

return {
	link = function ( frame )
		return link_to_dashboard( dashboard_def, 'Community Tech', 'Community Tech dashboard on Gerrit' ) .. ' <sup>[[Module:Gerrit dashboard/Community Tech|(source)]]</sup>'
	end
}