Class: AgingWorkTable
Instance Attribute Summary collapse
Attributes inherited from ChartBase
#aggregated_project, #all_boards, #canvas_height, #canvas_width, #data_quality, #date_range, #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_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
Returns a new instance of AgingWorkTable.
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/jirametrics/aging_work_table.rb', line 8
def initialize block
super()
@blocked_icon = '🛑'
@expedited_icon = '🔥'
@stalled_icon = '🟧'
@stalled_threshold = 5
@dead_icon = '⬛'
@dead_threshold = 45
@age_cutoff = 0
instance_eval(&block) if block
end
|
Instance Attribute Details
Returns the value of attribute board_id.
6
7
8
|
# File 'lib/jirametrics/aging_work_table.rb', line 6
def board_id
@board_id
end
|
Returns the value of attribute today.
6
7
8
|
# File 'lib/jirametrics/aging_work_table.rb', line 6
def today
@today
end
|
Instance Method Details
#age_cutoff(age = nil) ⇒ Object
126
127
128
129
|
# File 'lib/jirametrics/aging_work_table.rb', line 126
def age_cutoff age = nil
@age_cutoff = age.to_i if age
@age_cutoff
end
|
#any_scrum_boards? ⇒ Boolean
131
132
133
|
# File 'lib/jirametrics/aging_work_table.rb', line 131
def any_scrum_boards?
@any_scrum_boards
end
|
#blocked_text(issue) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/jirametrics/aging_work_table.rb', line 60
def blocked_text issue
started_time = issue.board.cycletime.started_time(issue)
return nil if started_time.nil?
current = issue.blocked_stalled_changes(end_time: time_range.end)[-1]
if current.blocked?
icon_span title: current.reasons, icon: @blocked_icon
elsif current.stalled?
if current.stalled_days && current.stalled_days > @dead_threshold
icon_span(
title: "Dead? Hasn't had any activity in #{label_days current.stalled_days}. " \
'Does anyone still care about this?',
icon: @dead_icon
)
else
icon_span(
title: current.reasons,
icon: @stalled_icon
)
end
end
end
|
#current_status_visible?(issue) ⇒ Boolean
122
123
124
|
# File 'lib/jirametrics/aging_work_table.rb', line 122
def current_status_visible? issue
issue.board.visible_columns.any? { |column| column.status_ids.include? issue.status.id }
end
|
#expedited_text(issue) ⇒ Object
53
54
55
56
57
58
|
# File 'lib/jirametrics/aging_work_table.rb', line 53
def expedited_text issue
return unless issue.expedited?
name = issue.raw['fields']['priority']['name']
icon_span(title: "Expedited: Has a priority of "#{name}"", icon: @expedited_icon)
end
|
#fix_versions_text(issue) ⇒ Object
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/jirametrics/aging_work_table.rb', line 90
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
|
#icon_span(title:, icon:) ⇒ Object
49
50
51
|
# File 'lib/jirametrics/aging_work_table.rb', line 49
def icon_span title:, icon:
"<span title='#{title}' style='font-size: 0.8em;'>#{icon}</span>"
end
|
#parent_hierarchy(issue) ⇒ Object
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
# File 'lib/jirametrics/aging_work_table.rb', line 135
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
|
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/jirametrics/aging_work_table.rb', line 21
def run
@today = date_range.end
aging_issues = select_aging_issues
expedited_but_not_started = @issues.select do |issue|
cycletime = issue.board.cycletime
cycletime.started_time(issue).nil? && cycletime.stopped_time(issue).nil? && issue.expedited?
end
aging_issues += expedited_but_not_started.sort_by(&:created)
render(binding, __FILE__)
end
|
#select_aging_issues ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/jirametrics/aging_work_table.rb', line 34
def select_aging_issues
aging_issues = @issues.select do |issue|
cycletime = issue.board.cycletime
started = cycletime.started_time(issue)
stopped = cycletime.stopped_time(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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/jirametrics/aging_work_table.rb', line 101
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
|
#unmapped_status_text(issue) ⇒ Object
83
84
85
86
87
88
|
# File 'lib/jirametrics/aging_work_table.rb', line 83
def unmapped_status_text issue
icon_span(
title: "The status #{issue.status.name.inspect} is not mapped to any column and will not be visible",
icon: ' ⁉️'
)
end
|