Class: AgingWorkTable
Constant Summary
Constants inherited
from ChartBase
ChartBase::LABEL_POSITIONS, ChartBase::OKABE_ITO_PALETTE
Instance Attribute Summary collapse
Attributes inherited from ChartBase
#aggregated_project, #all_boards, #atlassian_document_format, #board_id, #canvas_height, #canvas_width, #color_palette, #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
validate_percentile, validate_percentiles
Methods inherited from ChartBase
#aggregated_project?, #before_run, #call_before_run, #canvas, #canvas_responsive?, #chart_format, #collapsible_issues_panel, #color_block, #color_for, #comma_and, #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, #next_palette_color, #non_working_day?, #normalize_annotation_datetime, #not_visible_icon, #not_visible_text, #ordinal, #percentile_of, #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
Returns a new instance of AgingWorkTable.
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/jirametrics/aging_work_table.rb', line 13
def initialize block
super()
@stalled_threshold = 5
@dead_threshold = 45
@age_cutoff = 0
@percentile = 85
'Aging Work Table'
description_text <<-TEXT
<div class="p">
This chart shows all active (started but not completed) work, ordered from oldest at the top to
newest at the bottom.
</div>
<div class="p">
If there are expedited items that haven't yet started then they're at the bottom of the table.
By the very definition of expedited, if we haven't started them already, we'd better get on that.
</div>
<div class="p">
Legend:
<ul>
<li><b>E:</b> Whether this item is <b>E</b>xpedited.</li>
<li><b>B/S:</b> Whether this item is either <b>B</b>locked or <b>S</b>talled.</li>
<li><b>Forecast:</b> A forecast of how long it is likely to take to finish this work item.</li>
</ul>
</div>
TEXT
instance_eval(&block)
end
|
Instance Attribute Details
#any_scrum_boards ⇒ Object
Returns the value of attribute any_scrum_boards.
11
12
13
|
# File 'lib/jirametrics/aging_work_table.rb', line 11
def any_scrum_boards
@any_scrum_boards
end
|
#today ⇒ Object
Returns the value of attribute today.
10
11
12
|
# File 'lib/jirametrics/aging_work_table.rb', line 10
def today
@today
end
|
Instance Method Details
#age_cutoff(age = nil) ⇒ Object
176
177
178
179
|
# File 'lib/jirametrics/aging_work_table.rb', line 176
def age_cutoff age = nil
@age_cutoff = age.to_i if age
@age_cutoff
end
|
#aging_issue?(issue) ⇒ Boolean
An issue is "aging" if it's in progress and either flagged as needing attention (blocked or
expedited) or older than the configured cutoff.
75
76
77
78
79
80
81
|
# File 'lib/jirametrics/aging_work_table.rb', line 75
def aging_issue? issue
cycletime = issue.board.cycletime
return false unless cycletime.in_progress?(issue)
return true if issue.blocked_on_date?(@today, end_time: time_range.end) || issue.expedited?
cycletime.age(issue, today: @today) > @age_cutoff
end
|
#blocked_text(issue) ⇒ Object
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/jirametrics/aging_work_table.rb', line 90
def blocked_text issue
started_time, _stopped_time = issue.started_stopped_times
return nil if started_time.nil?
current = issue.blocked_stalled_changes(end_time: time_range.end)[-1]
if current.blocked?
color_block '--blocked-color', title: current.reasons
elsif current.stalled?
if current.stalled_days && current.stalled_days > @dead_threshold
color_block(
'--dead-color',
title: "Dead? Hasn't had any activity in #{label_days current.stalled_days}. " \
'Does anyone still care about this?'
)
else
color_block '--stalled-color', title: current.reasons
end
end
end
|
#dates_text(issue) ⇒ Object
133
134
135
136
137
138
139
140
141
|
# File 'lib/jirametrics/aging_work_table.rb', line 133
def dates_text issue
days_remaining, error = @calculators[issue.board.id].forecasted_days_remaining_and_message(
issue: issue, today: @today, percentile: percentile
)
message = nil
message, error = due_date_status(issue, days_remaining, error) unless error
forecast_line days_remaining, error, message
end
|
#due_date_status(issue, days_remaining, error) ⇒ Object
Returns [message, error] describing where the due date sits relative to today and the forecast:
overdue, due today, or a future date that may be at risk. Only called when the forecast succeeded.
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
# File 'lib/jirametrics/aging_work_table.rb', line 145
def due_date_status issue, days_remaining, error
due = issue.due_date
return [nil, error] unless due
date = date_range.end
if due < date
["Due: <b>#{due}</b> (#{label_days (@today - due).to_i} ago)", 'Overdue']
elsif due == date
['Due: <b>today</b>', error]
else
at_risk = date_range.end + days_remaining > due
["Due: <b>#{due}</b> (#{label_days (due - @today).to_i})", at_risk ? 'Due date at risk' : error]
end
end
|
#expedited_but_not_started ⇒ Object
60
61
62
63
64
65
|
# File 'lib/jirametrics/aging_work_table.rb', line 60
def expedited_but_not_started
@issues.select do |issue|
started_time, stopped_time = issue.started_stopped_times
started_time.nil? && stopped_time.nil? && issue.expedited?
end.sort_by(&:created)
end
|
#expedited_text(issue) ⇒ Object
83
84
85
86
87
88
|
# File 'lib/jirametrics/aging_work_table.rb', line 83
def expedited_text issue
return unless issue.expedited?
name = issue.raw['fields']['priority']['name']
color_block '--expedited-color', title: "Expedited: Has a priority of "#{name}""
end
|
#fix_versions_text(issue) ⇒ Object
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/jirametrics/aging_work_table.rb', line 110
def fix_versions_text issue
issue.fix_versions.collect do |fix|
if fix.released?
icon_text = icon_span title: 'Released. Likely not on the board anymore.', icon: '✅'
"#{fix.name} #{icon_text}"
else
fix.name
end
end.join('<br />')
end
|
#forecast_line(days_remaining, error, message) ⇒ Object
160
161
162
163
164
165
166
|
# File 'lib/jirametrics/aging_work_table.rb', line 160
def forecast_line days_remaining, error, message
text = +''
text << "<span title='#{error}' style='color: red'>ⓘ </span>" if error
text << (days_remaining ? "#{label_days days_remaining} left" : 'Unable to forecast')
text << ' | ' << message if message
text
end
|
#initialize_calculator ⇒ Object
This is its own method simply so the tests can initialize the calculator without doing a full run.
53
54
55
56
57
58
|
# File 'lib/jirametrics/aging_work_table.rb', line 53
def initialize_calculator
@today = date_range.end
@calculators = @all_boards.transform_values do |board|
BoardMovementCalculator.new board: board, issues: issues, today: @today
end
end
|
#parent_hierarchy(issue) ⇒ Object
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
# File 'lib/jirametrics/aging_work_table.rb', line 181
def parent_hierarchy issue
result = []
while issue
cyclical_parent_links = result.include? issue
result << issue
break if cyclical_parent_links
issue = issue.parent
end
result.reverse
end
|
#percentile(value = nil) ⇒ Object
Which percentile of historical column movement the Forecast column is based on. Singular,
unlike the charts' "percentiles", because a forecast has to resolve to one number of days: the
due date risk calculation compares that single figure against the due date.
171
172
173
174
|
# File 'lib/jirametrics/aging_work_table.rb', line 171
def percentile value = nil
@percentile = validate_percentile(value) unless value.nil?
@percentile
end
|
#priority_text(issue) ⇒ Object
196
197
198
|
# File 'lib/jirametrics/aging_work_table.rb', line 196
def priority_text issue
"<img src='#{issue.priority_url}' title='Priority: #{issue.priority_name}' style='max-width: 1em;'/>"
end
|
#run ⇒ Object
45
46
47
48
49
50
|
# File 'lib/jirametrics/aging_work_table.rb', line 45
def run
initialize_calculator
aging_issues = select_aging_issues + expedited_but_not_started
wrap_and_render(binding, __FILE__)
end
|
#select_aging_issues ⇒ Object
67
68
69
70
71
|
# File 'lib/jirametrics/aging_work_table.rb', line 67
def select_aging_issues
aging_issues = @issues.select { |issue| aging_issue? issue }
@any_scrum_boards = aging_issues.any? { |issue| issue.board.scrum? }
aging_issues.sort_by { |issue| -issue.board.cycletime.age(issue, today: @today) }
end
|
#sprints_text(issue) ⇒ Object
121
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/jirametrics/aging_work_table.rb', line 121
def sprints_text issue
issue.sprints.collect do |sprint|
icon_text = nil
if sprint.active?
icon_text = icon_span title: 'Active sprint', icon: '➡️'
elsif sprint.closed?
icon_text = icon_span title: 'Sprint closed', icon: '✅'
end
"#{sprint.name} #{icon_text}"
end.join('<br />')
end
|