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, #atlassian_document_format, #board_id, #canvas_height, #canvas_width, #data_quality, #date_range, #file_system, #holiday_dates, #issues, #settings, #time_range, #timezone_offset
Instance Method Summary collapse
- #calculate_time_periods ⇒ Object
-
#initialize(block) ⇒ 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_block, #color_for, #completed_issues_in_range, #current_board, #daily_chart_dataset, #describe_non_working_days, #description_text, #format_integer, #format_status, #header_text, #holidays, #html_directory, #icon_span, #label_days, #label_issues, #link_to_issue, #next_id, #random_color, #render, #render_top_text, #status_category_color, #working_days_annotation, #wrap_and_render
Constructor Details
#initialize(block) ⇒ ThroughputChart
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jirametrics/throughput_chart.rb', line 8 def initialize block super() header_text 'Throughput Chart' description_text " <div class=\"p\">\n This chart shows how many items we completed per week\n </div>\n \#{describe_non_working_days}\n TEXT\n\n init_configuration_block(block) do\n grouping_rules do |issue, rule|\n rule.label = issue.type\n rule.color = color_for type: issue.type\n end\n end\nend\n" |
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
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/jirametrics/throughput_chart.rb', line 49 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
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/jirametrics/throughput_chart.rb', line 27 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: CssVariable['--throughput_chart_total_line_color'], 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
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/jirametrics/throughput_chart.rb', line 82 def throughput_dataset periods:, completed_issues: periods.collect do |period| closed_issues = completed_issues.filter_map do |issue| stop_date = issue.board.cycletime.started_stopped_dates(issue).last [stop_date, issue] if stop_date && period.include?(stop_date) end 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
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/jirametrics/throughput_chart.rb', line 68 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 |