Module:Gerrit dashboard/Multimedia

From Guild of Archivists
Revision as of 07:26, 30 October 2015 by Alahmnat (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Gerrit dashboard/Multimedia/doc

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( 'marktraceur', 'MarkTraceur' )
-- add_team_member( 'bd808', 'BryanDavis' )
add_team_member( 'Gergő Tisza', '"Gergő Tisza"' )
add_team_member( 'Gilles', 'Gilles' )
-- add_team_member( 'Aarcos', '"Aaron Arcos"' )

add_ext( 'BetaFeatures' )
add_ext( 'MultimediaViewer' )
add_ext( 'CommonsMetadata' )
add_proj( 'mediawiki/core', 'Core' )
add_proj( 'operations/mediawiki-config', 'Config' )
add_ext( 'UploadWizard' )

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, 'Multimedia', 'Multimedia dashboard on Gerrit' ) .. ' <sup>[[Module:Gerrit dashboard/Multimedia|(source)]]</sup>'
	end
}