Class: McpServer::AgingWorkTool

Inherits:
MCP::Tool
  • Object
show all
Defined in:
lib/jirametrics/mcp_server.rb

Class Method Summary collapse

Class Method Details

.build_row(issue:, project_name:, project_data:, min_age_days:, current_status:, current_column:, filter:) ⇒ Object



278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/jirametrics/mcp_server.rb', line 278

def self.build_row issue:, project_name:, project_data:, min_age_days:, current_status:, current_column:, filter:
  started, stopped = issue.started_stopped_times
  return nil unless started && !stopped
  return nil unless McpServer.matches_current_state?(issue, current_status, current_column)

  age = (project_data[:today] - started.to_date).to_i + 1
  return nil if min_age_days && age < min_age_days
  return nil unless McpServer.matches_history?(issue, project_data[:end_time], filter)

  {
    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

.call(server_context:, min_age_days: nil, project: nil, project_name: nil, current_status: nil, current_column: nil, **history_args) ⇒ Object



262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/jirametrics/mcp_server.rb', line 262

def self.call(server_context:, min_age_days: nil, project: nil, project_name: nil,
              current_status: nil, current_column: nil, **history_args)
  project ||= project_name
  filter = McpServer::HistoryFilter.from(**history_args)

  rows = McpServer.collect_rows(server_context, project) do |issue, name, project_data|
    build_row(
      issue: issue, project_name: name, project_data: project_data, min_age_days: min_age_days,
      current_status: current_status, current_column: current_column, filter: filter
    )
  end
  rows.sort_by! { |r| -r[:age_days] }

  McpServer.render_rows(rows, empty: 'No aging work found.') { |r| format_line(r) }
end

.format_line(row) ⇒ Object



298
299
300
301
302
# File 'lib/jirametrics/mcp_server.rb', line 298

def self.format_line row
  fe = row[:flow_efficiency] ? " | FE: #{row[:flow_efficiency]}%" : ''
  "#{row[:key]} | #{row[:project]} | #{row[:type]} | #{row[:status]} | " \
    "Age: #{row[:age_days]}d#{fe} | #{row[:summary]}"
end