Class: PullRequestCycleTimeScatterplot

Inherits:
TimeBasedScatterplot show all
Defined in:
lib/jirametrics/pull_request_cycle_time_scatterplot.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 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 TimeBasedScatterplot

#calculate_percent_line, #create_datasets, #data_for_item, #minimum_y_value, #run, #show_trend_lines, #trend_line_data_set, #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) ⇒ PullRequestCycleTimeScatterplot

Returns a new instance of PullRequestCycleTimeScatterplot.



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

def initialize block
  super()

  @y_axis_title = 'Cycle time in days'

  header_text 'Pull Request (PR) Scatterplot'
  description_text <<-HTML
    <div class="p">
      This graph shows the cycle time for all closed pull requests (time from opened to closed).
    </div>
    #{describe_non_working_days}
  HTML

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

Instance Method Details

#additions_deletions_summary(pull_request) ⇒ Object

The "+10 -4" bit: each side only appears when non-zero, joined by a space only when both do.



58
59
60
61
62
63
64
65
# File 'lib/jirametrics/pull_request_cycle_time_scatterplot.rb', line 58

def additions_deletions_summary pull_request
  additions = pull_request.additions || 0
  deletions = pull_request.deletions || 0
  parts = []
  parts << "+#{to_human_readable additions}" unless additions.zero?
  parts << "-#{to_human_readable deletions}" unless deletions.zero?
  parts.join(' ')
end

#all_itemsObject



26
27
28
29
30
31
32
33
34
# File 'lib/jirametrics/pull_request_cycle_time_scatterplot.rb', line 26

def all_items
  result = []
  issues.each do |issue|
    issue.github_prs&.each do |pr|
      result << pr if pr.closed_at
    end
  end
  result
end

#lines_changed_text(pull_request) ⇒ Object



50
51
52
53
54
55
# File 'lib/jirametrics/pull_request_cycle_time_scatterplot.rb', line 50

def lines_changed_text pull_request
  return '' unless pull_request.changed_files

  summary = additions_deletions_summary pull_request
  " | Lines changed: [#{summary}], Files changed: #{to_human_readable pull_request.changed_files}"
end

#title_value(pull_request, rules: nil) ⇒ Object



44
45
46
47
48
# File 'lib/jirametrics/pull_request_cycle_time_scatterplot.rb', line 44

def title_value pull_request, rules: nil
  age_label = label_cycletime y_value(pull_request)
  keys = pull_request.issue_keys.join(', ')
  "#{keys} | #{pull_request.title} | #{rules.label} | Age:#{age_label}#{lines_changed_text(pull_request)}"
end

#x_value(pull_request) ⇒ Object



36
37
38
# File 'lib/jirametrics/pull_request_cycle_time_scatterplot.rb', line 36

def x_value pull_request
  pull_request.closed_at
end

#y_value(pull_request) ⇒ Object



40
41
42
# File 'lib/jirametrics/pull_request_cycle_time_scatterplot.rb', line 40

def y_value pull_request
  duration_in_unit pull_request.opened_at, pull_request.closed_at
end