Module:Gerrit dashboard
All Gerrit dashboard sub modules:
Module:Gerrit dashboard constructs gerrit URLs that produce useful dashboards. The subpages of this module (listed above) construct particular dashboard URLs when invoked, for example
{{#invoke:Gerrit dashboard/Multimedia|link}}
produces
local UrlEncoding = require( 'Module:UrlEncoding' )
local encode = UrlEncoding._encode
local get_search_string
get_search_string = function ( target, joiner )
local tbl = {}
local key
joiner = joiner or '+'
for _, val in ipairs( target ) do
key = val[1]
val = val[2]
if key == 'AND' then
table.insert( tbl, encode( '(' ) .. get_search_string( val, '+AND+' ) .. encode( ')' ) )
elseif key == 'OR' then
table.insert( tbl, encode( '(' ) .. get_search_string( val, '+OR+' ) .. encode( ')' ) )
elseif key == 'NOT' then
table.insert( tbl, 'NOT+' .. get_search_string( { val } ) )
else
table.insert( tbl, encode( key ) .. ':' .. encode( val ) )
end
end
return table.concat( tbl, joiner )
end
local get_dashboards = function ( target )
local tbl = {}
local name = ''
for _, tgt in ipairs( target ) do
name = tgt[1]
tgt = tgt[2]
table.insert( tbl, encode( name ) .. '=' .. get_search_string( tgt ) )
end
return table.concat( tbl, '&' )
end
local link_to_dashboard = function ( target, title, text )
text = text or 'Dashboard'
return '[https://gerrit.wikimedia.org/r/#/dashboard/?title=' .. encode( title ) .. '&' .. get_dashboards( target ) .. ' ' .. text .. ']'
end
return {
_link_to_dashboard = link_to_dashboard,
link = function ( frame )
return link_to_dashboard( frame.args )
end
}