219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
# File 'lib/jirametrics/mcp_server.rb', line 219
def self.call(server_context:, min_age_days: nil, project: nil, project_name: nil,
current_status: nil, current_column: nil,
history_field: nil, history_value: nil, ever_blocked: nil, ever_stalled: nil,
currently_blocked: nil, currently_stalled: nil, **)
project ||= project_name
rows = []
allowed_projects = McpServer.resolve_projects(server_context, project)
server_context[:projects].each do |project_name, project_data|
next if allowed_projects && !allowed_projects.include?(project_name)
today = project_data[:today]
project_data[:issues].each do |issue|
started, stopped = issue.started_stopped_times
next unless started && !stopped
next if current_status && issue.status.name != current_status
next if current_column && McpServer.column_name_for(issue.board, issue.status.id) != current_column
age = (today - started.to_date).to_i + 1
next if min_age_days && age < min_age_days
unless McpServer.matches_history?(issue, project_data[:end_time],
history_field, history_value, ever_blocked, ever_stalled,
currently_blocked, currently_stalled)
next
end
rows << {
key: issue.key,
summary: issue.summary,
status: issue.status.name,
type: issue.type,
age_days: age,
flow_efficiency: McpServer.flow_efficiency_percent(issue, project_data[:end_time]),
project: project_name
}
end
end
rows.sort_by! { |r| -r[:age_days] }
if rows.empty?
text = 'No aging work found.'
else
lines = rows.map do |r|
fe = r[:flow_efficiency] ? " | FE: #{r[:flow_efficiency]}%" : ''
"#{r[:key]} | #{r[:project]} | #{r[:type]} | #{r[:status]} | Age: #{r[:age_days]}d#{fe} | #{r[:summary]}"
end
text = lines.join("\n")
end
MCP::Tool::Response.new([{ type: 'text', text: text }])
end
|