Class: PullRequestCycleTimeScatterplot
Constant Summary
Constants inherited
from ChartBase
ChartBase::LABEL_POSITIONS
Instance Attribute Summary
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
#calculate_percent_line, #create_datasets, #data_for_item, #minimum_y_value, #run, #show_trend_lines, #trend_line_data_set
#group_issues, #grouping_rules, #init_configuration_block
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, #label_days, #label_hours, #label_issues, #label_minutes, #link_to_issue, #next_id, #normalize_annotation_datetime, #not_visible_text, #random_color, #render, #render_axis_title, #render_top_text, #seam_end, #seam_start, #stagger_label_positions, #status_category_color, #to_human_readable, #working_days_annotation, #wrap_and_render
Constructor Details
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
25
|
# File 'lib/jirametrics/pull_request_cycle_time_scatterplot.rb', line 6
def initialize block
super()
@cycletime_unit = :days
@y_axis_title = 'Cycle time in days'
'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|
rules.label = pull_request.repo
end
end
end
|
Instance Method Details
#all_items ⇒ Object
36
37
38
39
40
41
42
43
44
|
# File 'lib/jirametrics/pull_request_cycle_time_scatterplot.rb', line 36
def all_items
result = []
issues.each do |issue|
issue.github_prs&.each do |pr|
result << pr if pr.closed_at
end
end
result
end
|
#cycletime_unit(unit) ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'lib/jirametrics/pull_request_cycle_time_scatterplot.rb', line 27
def cycletime_unit unit
unless %i[minutes hours days].include?(unit)
raise ArgumentError, "cycletime_unit must be :minutes, :hours, or :days, got #{unit.inspect}"
end
@cycletime_unit = unit
@y_axis_title = "Cycle time in #{unit}"
end
|
#label_cycletime(value) ⇒ Object
55
56
57
58
59
60
61
|
# File 'lib/jirametrics/pull_request_cycle_time_scatterplot.rb', line 55
def label_cycletime value
case @cycletime_unit
when :minutes then label_minutes(value)
when :hours then label_hours(value)
when :days then label_days(value)
end
end
|
#lines_changed_text(pull_request) ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/jirametrics/pull_request_cycle_time_scatterplot.rb', line 68
def lines_changed_text pull_request
return '' unless pull_request.changed_files
additions = pull_request.additions || 0
deletions = pull_request.deletions || 0
text = +' | Lines changed: ['
text << "+#{to_human_readable additions}" unless additions.zero?
text << ' ' if additions != 0 && deletions != 0
text << "-#{to_human_readable deletions}" unless deletions.zero?
text << "], Files changed: #{to_human_readable pull_request.changed_files}"
text
end
|
#title_value(pull_request, rules: nil) ⇒ Object
63
64
65
66
|
# File 'lib/jirametrics/pull_request_cycle_time_scatterplot.rb', line 63
def title_value pull_request, rules: nil
age_label = label_cycletime y_value(pull_request)
"#{pull_request.title} | #{rules.label} | Age:#{age_label}#{lines_changed_text(pull_request)}"
end
|
#x_value(pull_request) ⇒ Object
46
47
48
|
# File 'lib/jirametrics/pull_request_cycle_time_scatterplot.rb', line 46
def x_value pull_request
pull_request.closed_at
end
|
#y_value(pull_request) ⇒ Object
50
51
52
53
|
# File 'lib/jirametrics/pull_request_cycle_time_scatterplot.rb', line 50
def y_value pull_request
divisor = { minutes: 60, hours: 3600, days: 86_400 }[@cycletime_unit]
((pull_request.closed_at - pull_request.opened_at) / divisor).round
end
|