Class: ThroughputChart
- Includes:
- GroupableIssueChart
- Defined in:
- lib/jirametrics/throughput_chart.rb
Instance Attribute Summary collapse
-
#possible_statuses ⇒ Object
Returns the value of attribute possible_statuses.
Attributes inherited from ChartBase
#aggregated_project, #all_boards, #board_id, #canvas_height, #canvas_width, #data_quality, #date_range, #holiday_dates, #issues, #settings, #time_range, #timezone_offset
Instance Method Summary collapse
- #calculate_time_periods ⇒ Object
-
#initialize(block = nil) ⇒ ThroughputChart
constructor
A new instance of ThroughputChart.
- #run ⇒ Object
- #throughput_dataset(periods:, completed_issues:) ⇒ Object
- #weekly_throughput_dataset(completed_issues:, label:, color:, dashed: false) ⇒ Object
Methods included from GroupableIssueChart
#group_issues, #grouping_rules, #init_configuration_block
Methods inherited from ChartBase
#aggregated_project?, #canvas, #canvas_responsive?, #chart_format, #collapsible_issues_panel, #color_for, #completed_issues_in_range, #current_board, #daily_chart_dataset, #description_text, #filter_issues, #format_integer, #format_status, #header_text, #holidays, #label_days, #label_issues, #link_to_issue, #next_id, #random_color, #render, #sprints_in_time_range, #status_category_color, #wrap_and_render
Constructor Details
#initialize(block = nil) ⇒ ThroughputChart
Returns a new instance of ThroughputChart.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/jirametrics/throughput_chart.rb', line 8 def initialize block = nil super() header_text 'Throughput Chart' description_text 'This chart shows how many items we completed per unit of time' init_configuration_block(block) do grouping_rules do |issue, rule| rule.label = issue.type rule.color = color_for type: issue.type end end end |
Instance Attribute Details
#possible_statuses ⇒ Object
Returns the value of attribute possible_statuses.
6 7 8 |
# File 'lib/jirametrics/throughput_chart.rb', line 6 def possible_statuses @possible_statuses end |
Instance Method Details
#calculate_time_periods ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/jirametrics/throughput_chart.rb', line 41 def calculate_time_periods first_day = @date_range.begin first_day = case first_day.wday when 0 then first_day + 1 when 1 then first_day else first_day + (8 - first_day.wday) end periods = [] loop do last_day = first_day + 6 return periods unless @date_range.include? last_day periods << (first_day..last_day) first_day = last_day + 1 end end |
#run ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/jirametrics/throughput_chart.rb', line 22 def run completed_issues = completed_issues_in_range include_unstarted: true rules_to_issues = group_issues completed_issues data_sets = [] if rules_to_issues.size > 1 data_sets << weekly_throughput_dataset( completed_issues: completed_issues, label: 'Totals', color: 'gray', dashed: true ) end rules_to_issues.each_key do |rules| data_sets << weekly_throughput_dataset( completed_issues: rules_to_issues[rules], label: rules.label, color: rules.color ) end wrap_and_render(binding, __FILE__) end |
#throughput_dataset(periods:, completed_issues:) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/jirametrics/throughput_chart.rb', line 74 def throughput_dataset periods:, completed_issues: periods.collect do |period| closed_issues = completed_issues.collect do |issue| stop_date = issue.board.cycletime.stopped_time(issue)&.to_date [stop_date, issue] if stop_date && period.include?(stop_date) end.compact date_label = "on #{period.end}" date_label = "between #{period.begin} and #{period.end}" unless period.begin == period.end { y: closed_issues.size, x: "#{period.end}T23:59:59", title: ["#{closed_issues.size} items completed #{date_label}"] + closed_issues.collect { |_stop_date, issue| "#{issue.key} : #{issue.summary}" } } end end |
#weekly_throughput_dataset(completed_issues:, label:, color:, dashed: false) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/jirametrics/throughput_chart.rb', line 60 def weekly_throughput_dataset completed_issues:, label:, color:, dashed: false result = { label: label, data: throughput_dataset(periods: calculate_time_periods, completed_issues: completed_issues), fill: false, showLine: true, borderColor: color, lineTension: 0.4, backgroundColor: color } result['borderDash'] = [10, 5] if dashed result end |