Class: AgingWorkTable
Instance Attribute Summary collapse
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 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
Returns a new instance of AgingWorkTable.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/jirametrics/aging_work_table.rb', line 9
def initialize block
super()
@stalled_threshold = 5
@dead_threshold = 45
@age_cutoff = 0
'Aging Work Table'
description_text <<-TEXT
<p>
This chart shows all active (started but not completed) work, ordered from oldest at the top to
newest at the bottom.
</p>
<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.
</p>
<p>
Legend:
<ul><li><b>FD:</b> <b>F</b>orecasted <b>D</b>ays remaining. A hint of how long it will likely take
to complete, based on historical data for this same board.</li>
<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>
</ul>
</p>
TEXT
instance_eval(&block)
end
|
Instance Attribute Details
#any_scrum_boards ⇒ Object
Returns the value of attribute any_scrum_boards.
7
8
9
|
# File 'lib/jirametrics/aging_work_table.rb', line 7
def any_scrum_boards
@any_scrum_boards
end
|
#today ⇒ Object
6
7
8
|
# File 'lib/jirametrics/aging_work_table.rb', line 6
def today
@today
end
|
Instance Method Details
#age_cutoff(age = nil) ⇒ Object
187
188
189
190
|
# File 'lib/jirametrics/aging_work_table.rb', line 187
def age_cutoff age = nil
@age_cutoff = age.to_i if age
@age_cutoff
end
|
#blocked_text(issue) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/jirametrics/aging_work_table.rb', line 73
def blocked_text issue
started_time, _stopped_time = issue.board.cycletime.started_stopped_times(issue)
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
# File 'lib/jirametrics/aging_work_table.rb', line 152
def dates_text issue
color = nil
title = nil
date = date_range.end
due = issue.due_date
return '' unless due
if date == due
color = '--aging-work-table-date-in-jeopardy'
title = 'Item is due today and is still in progress'
elsif date > due
color = '--aging-work-table-date-overdue'
title = 'Item is already overdue.'
else
days_remaining, message = forecasted_days_remaining_and_message issue
if message
color = '--aging-work-table-date-in-jeopardy'
title = message
elsif date_range.end + days_remaining > due
color = '--aging-work-table-date-in-jeopardy'
due_days_label = label_days (due - date_range.end).to_i
title = "Likely to need another #{days_remaining} days and it's due in #{due_days_label}"
end
end
result = +''
result << color_block(color)
result << ' '
result << due.to_s
result << "<br /><span style='font-size: 0.8em'>#{title}</span>" if title
result
end
|
#expedited_but_not_started ⇒ Object
45
46
47
48
49
50
|
# File 'lib/jirametrics/aging_work_table.rb', line 45
def expedited_but_not_started
@issues.select do |issue|
started_time, stopped_time = issue.board.cycletime.started_stopped_times(issue)
started_time.nil? && stopped_time.nil? && issue.expedited?
end.sort_by(&:created)
end
|
#expedited_text(issue) ⇒ Object
66
67
68
69
70
71
|
# File 'lib/jirametrics/aging_work_table.rb', line 66
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
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/jirametrics/aging_work_table.rb', line 93
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
|
#forecasted_days_remaining_and_message(issue) ⇒ Object
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
# File 'lib/jirametrics/aging_work_table.rb', line 125
def forecasted_days_remaining_and_message issue
calculator = BoardMovementCalculator.new board: current_board, issues: issues
column_name, entry_time = calculator.find_current_column_and_entry_time_in_column issue
return [nil, 'This issue is not visible on the board. No way to predict when it will be done.'] if column_name.nil?
@likely_age_data = calculator.age_data_for percentage: 85
age_in_column = (date_range.end - entry_time.to_date).to_i + 1
message = nil
column_index = current_board.visible_columns.index { |c| c.name == column_name }
last_non_zero_datapoint = @likely_age_data.reverse.find { |d| !d.zero? }
remaining_in_current_column = @likely_age_data[column_index] - age_in_column
if remaining_in_current_column.negative?
message = 'This item is an outlier. The actual time will likely be much greater than the forecast.'
remaining_in_current_column = 0
end
forecasted_days = last_non_zero_datapoint - @likely_age_data[column_index] + remaining_in_current_column
[forecasted_days, message]
end
|
#parent_hierarchy(issue) ⇒ Object
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
# File 'lib/jirametrics/aging_work_table.rb', line 192
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
|
#run ⇒ Object
38
39
40
41
42
43
|
# File 'lib/jirametrics/aging_work_table.rb', line 38
def run
@today = date_range.end
aging_issues = select_aging_issues + expedited_but_not_started
wrap_and_render(binding, __FILE__)
end
|
#select_aging_issues ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/jirametrics/aging_work_table.rb', line 52
def select_aging_issues
aging_issues = @issues.select do |issue|
cycletime = issue.board.cycletime
started, stopped = cycletime.started_stopped_times(issue)
next false if started.nil? || stopped
next true if issue.blocked_on_date?(@today, end_time: time_range.end) || issue.expedited?
age = (@today - started.to_date).to_i + 1
age > @age_cutoff
end
@any_scrum_boards = aging_issues.any? { |issue| issue.board.scrum? }
aging_issues.sort { |a, b| b.board.cycletime.age(b, today: @today) <=> a.board.cycletime.age(a, today: @today) }
end
|
#sprints_text(issue) ⇒ Object
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/jirametrics/aging_work_table.rb', line 104
def sprints_text issue
sprint_ids = []
issue.changes.each do |change|
next unless change.sprint?
sprint_ids << change.raw['to'].split(/\s*,\s*/).collect { |id| id.to_i }
end
sprint_ids.flatten!
issue.board.sprints.select { |s| sprint_ids.include? s.id }.collect do |sprint|
icon_text = nil
if sprint.active?
icon_text = icon_span title: 'Active sprint', icon: '➡️'
else
icon_text = icon_span title: 'Sprint closed', icon: '✅'
end
"#{sprint.name} #{icon_text}"
end.join('<br />')
end
|