Class: DailyWipByAgeChart

Inherits:
DailyWipChart show all
Defined in:
lib/jirametrics/daily_wip_by_age_chart.rb

Instance Attribute Summary

Attributes inherited from DailyWipChart

#possible_statuses

Attributes inherited from ChartBase

#aggregated_project, #all_boards, #board_id, #canvas_height, #canvas_width, #data_quality, #date_range, #file_system, #holiday_dates, #issues, #settings, #time_range, #timezone_offset

Instance Method Summary collapse

Methods inherited from DailyWipChart

#add_trend_line, #configure_rule, #group_issues_by_active_dates, #grouping_rules, #make_data_set, #run, #select_possible_rules, #trend_line_data_set

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, #icon_span, #label_days, #label_issues, #link_to_issue, #next_id, #random_color, #render, #render_top_text, #status_category_color, #wrap_and_render

Constructor Details

#initialize(block) ⇒ DailyWipByAgeChart

Returns a new instance of DailyWipByAgeChart.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/jirametrics/daily_wip_by_age_chart.rb', line 6

def initialize block
  super(block)

  add_trend_line line_color: '--aging-work-in-progress-by-age-trend-line-color', group_labels: [
    'Less than a day',
    'A week or less',
    'Two weeks or less',
    'Four weeks or less',
    'More than four weeks'
  ]
end

Instance Method Details

#default_description_textObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/jirametrics/daily_wip_by_age_chart.rb', line 22

def default_description_text
  <<-HTML
    <div class="p">
      This chart shows the highest WIP on each given day. The WIP is color coded so you can see
      how old it is and hovering over the bar will show you exactly which work items it relates
      to. The #{color_block '--wip-chart-completed-color'}
      #{color_block '--wip-chart-completed-but-not-started-color'}
      bars underneath, show how many items completed on that day.
    </div>
    <% if @has_completed_but_not_started %>
    <div class="p">
      #{color_block '--wip-chart-completed-but-not-started-color'} "Completed but not started"
      reflects the fact that while we know that it completed that day, we were unable to determine when
      it had started; it had moved directly from a To Do status to a Done status.
      The #{color_block '--body-background'} shading at the top shows when they might
      have been active. Note that the this grouping is approximate as we just don't know for sure.
    </div>
    <% end %>
    #{describe_non_working_days}
    <div class="p">
      The #{color_block '--aging-work-in-progress-by-age-trend-line-color'} dashed line is a general trend line.
      <% if @has_completed_but_not_started %>
      Note that this trend line only includes items where we know both the start and end times of
      the work so it may not be as accurate as we hope.
      <% end %>
    </div>
  HTML
end

#default_grouping_rules(issue:, rules:) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/jirametrics/daily_wip_by_age_chart.rb', line 51

def default_grouping_rules issue:, rules:
  cycletime = issue.board.cycletime
  started = cycletime.started_time(issue)&.to_date
  stopped = cycletime.stopped_time(issue)&.to_date

  rules.issue_hint = "(age: #{label_days (rules.current_date - started + 1).to_i})" if started

  if stopped && started.nil? # We can't tell when it started
    @has_completed_but_not_started = true
    not_started stopped: stopped, rules: rules, created: issue.created.to_date
  elsif stopped == rules.current_date
    stopped_today rules: rules
  else
    group_by_age started: started, rules: rules
  end
end

#default_header_textObject



18
19
20
# File 'lib/jirametrics/daily_wip_by_age_chart.rb', line 18

def default_header_text
  'Daily WIP grouped by Age'
end

#group_by_age(started:, rules:) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/jirametrics/daily_wip_by_age_chart.rb', line 88

def group_by_age started:, rules:
  age = rules.current_date - started + 1

  case age
  when 1
    rules.label = 'Less than a day'
    rules.color = '--wip-chart-duration-less-than-day-color'
    rules.group_priority = 10 # Highest is top
  when 2..7
    rules.label = 'A week or less'
    rules.color = '--wip-chart-duration-week-or-less-color'
    rules.group_priority = 9
  when 8..14
    rules.label = 'Two weeks or less'
    rules.color = '--wip-chart-duration-two-weeks-or-less-color'
    rules.group_priority = 8
  when 15..28
    rules.label = 'Four weeks or less'
    rules.color = '--wip-chart-duration-four-weeks-or-less-color'
    rules.group_priority = 7
  else
    rules.label = 'More than four weeks'
    rules.color = '--wip-chart-duration-more-than-four-weeks-color'
    rules.group_priority = 6
  end
end

#not_started(stopped:, rules:, created:) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/jirametrics/daily_wip_by_age_chart.rb', line 68

def not_started stopped:, rules:, created:
  if stopped == rules.current_date
    rules.label = 'Completed but not started'
    rules.color = '--wip-chart-completed-but-not-started-color'
    rules.group_priority = -1
  else
    rules.label = 'Start date unknown'
    rules.color = '--body-background'
    rules.group_priority = 11
    created_days = rules.current_date - created + 1
    rules.issue_hint = "(created: #{label_days created_days.to_i} earlier, stopped on #{stopped})"
  end
end

#stopped_today(rules:) ⇒ Object



82
83
84
85
86
# File 'lib/jirametrics/daily_wip_by_age_chart.rb', line 82

def stopped_today rules:
  rules.label = 'Completed'
  rules.color = '--wip-chart-completed-color'
  rules.group_priority = -2
end