Module:Gerrit dashboard

local UrlEncoding = require( 'Module:UrlEncoding' ) local encode = UrlEncoding._encode

local 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( encode( val ), '+AND+' ) .. encode( ')' ) ) elseif key == 'OR' then table.insert( tbl, encode( '(' ) .. get_search_string( encode( val ), '+OR+' ) .. encode( ')' ) ) else table.insert( encode( key ) .. ':' .. encode( val ) ) end end

return table.concat( tbl, joiner ) end

local get_dashboards = function ( target ) local tbl = {}

for name, tgt in pairs( target ) do 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 }