Class: PullRequestCycleTimeHistogram

Inherits:
TimeBasedHistogram show all
Defined in:
lib/jirametrics/pull_request_cycle_time_histogram.rb

Constant Summary

Constants inherited from TimeBasedChart

TimeBasedChart::VALUE_AXIS_LABELS

Constants inherited from ChartBase

ChartBase::LABEL_POSITIONS, ChartBase::OKABE_ITO_PALETTE

Instance Attribute Summary

Attributes inherited from TimeBasedHistogram

#show_stats

Attributes included from GroupableIssueChart

#group_by_block, #issue_hints, #issue_periods

Attributes inherited from ChartBase

#aggregated_project, #all_boards, #atlassian_document_format, #board_id, #canvas_height, #canvas_width, #data_quality, #date_range, #file_system, #fix_versions, #holiday_dates, #issues, #settings, #time_range, #timezone_offset, #x_axis_title, #y_axis_title

Instance Method Summary collapse

Methods inherited from TimeBasedHistogram

#average_for, #data_set_for, #disable_stats, #histogram_data_for, #modes_for, #percentiles, #percentiles_for, #run, #stats_for, #value_axis_title=

Methods included from GroupableIssueChart

#group_issues, #grouping_rules, #init_configuration_block

Methods inherited from TimeBasedChart

#cycletime_unit, #duration_in_unit, #label_cycletime

Methods inherited from ChartBase

#aggregated_project?, #before_run, #call_before_run, #canvas, #canvas_responsive?, #chart_format, #collapsible_issues_panel, #color_block, #color_for, #completed_issues_in_range, #current_board, #cycletime, #cycletime_for_issue, #daily_chart_dataset, #date_annotation, #describe_non_working_days, #description_text, #format_integer, #format_status, #header_text, #holidays, #html_directory, #icon_span, #link_to_issue, #next_id, #non_working_day?, #normalize_annotation_datetime, #not_visible_icon, #not_visible_text, #random_color, #render, #render_axis_title, #render_top_text, #resolve_status, #stagger_label_positions, #status_category_color, #to_human_readable, #working_days_annotation, #wrap_and_render

Constructor Details

#initialize(block) ⇒ PullRequestCycleTimeHistogram

Returns a new instance of PullRequestCycleTimeHistogram.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/jirametrics/pull_request_cycle_time_histogram.rb', line 6

def initialize block
  super()

  @x_axis_title = 'Cycle time in days'

  header_text 'PR Histogram'
  description_text <<-HTML
    <div class="p">
      This cycletime Histogram shows how many pull requests completed in a certain timeframe. This can be
      useful for determining how many different types of work are flowing through, based on the
      lengths of time they take.
    </div>
  HTML

  init_configuration_block(block) do
    grouping_rules do |pull_request, rule|
      rule.label = pull_request.repo
    end
  end
end

Instance Method Details

#all_itemsObject



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/jirametrics/pull_request_cycle_time_histogram.rb', line 27

def all_items
  result = []
  issues.each do |issue|
    next unless issue.github_prs

    issue.github_prs.each do |pr|
      next unless pr.closed_at

      result << pr
    end
  end
  result.uniq
end

#label_for_item(item, hint:) ⇒ Object



53
54
55
56
57
# File 'lib/jirametrics/pull_request_cycle_time_histogram.rb', line 53

def label_for_item item, hint:
  label = "#{item.number} #{item.title}"
  label << hint if hint
  label
end

#sort_items(items) ⇒ Object



49
50
51
# File 'lib/jirametrics/pull_request_cycle_time_histogram.rb', line 49

def sort_items items
  items.sort_by(&:opened_at)
end

#title_for_item(count:, value:) ⇒ Object



45
46
47
# File 'lib/jirametrics/pull_request_cycle_time_histogram.rb', line 45

def title_for_item count:, value:
  "#{count} PR#{'s' unless count == 1} closed in #{label_cycletime value}"
end

#value_for_item(item) ⇒ Object



41
42
43
# File 'lib/jirametrics/pull_request_cycle_time_histogram.rb', line 41

def value_for_item item
  duration_in_unit item.opened_at, item.closed_at
end