Class: DailyView
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, #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
-
#assemble_issue_lines(issue, child:) ⇒ Object
-
#blocked_lines(blocked_stalled) ⇒ Object
-
#blocking_issue_lines(key, marker) ⇒ Object
The lines for one blocking issue: a foldable section embedding the issue when we have it, or a plain "no description found" line when we only know its key.
-
#due_date_line(issue) ⇒ Object
'Due: ...' with a relative 'today/in N days/N days ago' hint, highlighted when overdue.
-
#field_change_text(change, board) ⇒ Object
'Set to X' or 'Changed from Y to X' for a status/priority/assignee/duedate/issuetype change.
-
#history_text(change:, board:) ⇒ Object
-
#initialize(_block) ⇒ DailyView
constructor
A new instance of DailyView.
-
#issue_sorter ⇒ Object
-
#label_lines(issue) ⇒ Object
One 'Labels: ...' and/or 'Components: ...' line, each listing its non-empty collection as label spans.
-
#make_blocked_stalled_lines(issue) ⇒ Object
-
#make_child_lines(issue) ⇒ Object
-
#make_description_lines(issue) ⇒ Object
-
#make_history_lines(issue) ⇒ Object
-
#make_issue_label(issue:, done:) ⇒ Object
-
#make_not_visible_line(issue) ⇒ Object
-
#make_parent_lines(issue) ⇒ Object
-
#make_sprints_lines(issue) ⇒ Object
-
#make_stats_lines(issue:, done:) ⇒ Object
-
#make_title_line(issue:, done:) ⇒ Object
-
#progress_line(issue, done) ⇒ Object
'Cycletime: ...' for finished issues, otherwise 'Age: ...' (or '(Not Started)' when it hasn't started).
-
#render_issue(issue, child:) ⇒ Object
-
#run ⇒ Object
-
#select_aging_issues ⇒ Object
Methods inherited from ChartBase
#aggregated_project?, #before_run, #call_before_run, #canvas, #canvas_responsive?, #chart_format, #collapsible_issues_panel, #color_block, #color_for, #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, #non_working_day?, #normalize_annotation_datetime, #not_visible_icon, #not_visible_text, #random_color, #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
#initialize(_block) ⇒ DailyView
Returns a new instance of DailyView.
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/jirametrics/daily_view.rb', line 6
def initialize _block
super()
'Daily View'
description_text <<-HTML
<div class="p">
This view shows all the items (<%= aging_issues.count %>) you'll want to discuss during your daily
coordination meeting
(aka daily scrum, standup), in the order that you should be discussing them. The most important
items are at the top, and the least at the bottom.
</div>
<div class="p">
By default, we sort by priority first and then by age within each of those priorities.
Hover over the issue to make it stand out more.
</div>
HTML
end
|
Instance Attribute Details
#possible_statuses ⇒ Object
Returns the value of attribute possible_statuses.
4
5
6
|
# File 'lib/jirametrics/daily_view.rb', line 4
def possible_statuses
@possible_statuses
end
|
Instance Method Details
#assemble_issue_lines(issue, child:) ⇒ Object
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
# File 'lib/jirametrics/daily_view.rb', line 287
def assemble_issue_lines issue, child:
done = issue.done?
lines = []
lines << [make_title_line(issue: issue, done: done)]
lines << make_not_visible_line(issue)
lines += make_parent_lines(issue) unless child
lines += make_stats_lines(issue: issue, done: done)
unless done
lines += make_description_lines(issue)
lines += make_sprints_lines(issue)
lines += make_blocked_stalled_lines(issue)
lines += make_child_lines(issue)
lines += make_history_lines(issue)
end
lines.compact
end
|
#blocked_lines(blocked_stalled) ⇒ Object
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/jirametrics/daily_view.rb', line 92
def blocked_lines blocked_stalled
marker = color_block '--blocked-color'
lines = []
lines << ["#{marker} Blocked by flag"] if blocked_stalled.flag
lines << ["#{marker} Blocked by status: #{blocked_stalled.status}"] if blocked_stalled.blocked_by_status?
blocked_stalled.blocking_issue_keys&.each do |key|
lines.concat blocking_issue_lines(key, marker)
end
lines
end
|
#blocking_issue_lines(key, marker) ⇒ Object
The lines for one blocking issue: a foldable section embedding the issue when we have it, or a plain
"no description found" line when we only know its key.
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/jirametrics/daily_view.rb', line 105
def blocking_issue_lines key, marker
blocking_issue = issues.find_by_key key: key, include_hidden: true
return [["#{marker} Blocked by issue: #{key} (no description found)"]] unless blocking_issue
[
"<section><div class=\"foldable startFolded\">#{marker} Blocked by issue: " \
"#{make_issue_label issue: blocking_issue, done: blocking_issue.done?}</div>",
blocking_issue,
'</section>'
]
end
|
#due_date_line(issue) ⇒ Object
'Due: ...' with a relative 'today/in N days/N days ago' hint, highlighted when overdue. nil when
the issue has no due date.
175
176
177
178
179
180
181
182
183
184
185
186
187
|
# File 'lib/jirametrics/daily_view.rb', line 175
def due_date_line issue
return nil unless issue.due_date
days = (issue.due_date - date_range.end).to_i
relative =
if days.zero? then 'today'
elsif days.positive? then "in #{label_days days}"
else "#{label_days(-days)} ago"
end
content = "#{issue.due_date} (#{relative})"
content = "<span style='background: var(--warning-banner)'>#{content}</span>" if days.negative?
"Due: <b>#{content}</b>"
end
|
#field_change_text(change, board) ⇒ Object
'Set to X' or 'Changed from Y to X' for a status/priority/assignee/duedate/issuetype change. Status
values are rendered as coloured status labels; everything else is shown inspected.
249
250
251
252
253
254
255
256
257
258
|
# File 'lib/jirametrics/daily_view.rb', line 249
def field_change_text change, board
convertor = ->(value, _id) { value.inspect }
convertor = ->(_value, id) { format_status(board.possible_statuses.find_by_id(id), board: board) } if change.status?
to = convertor.call(change.value, change.value_id)
return "Set to #{to}" unless change.old_value
from = convertor.call(change.old_value, change.old_value_id)
"Changed from #{from} to #{to}"
end
|
#history_text(change:, board:) ⇒ Object
235
236
237
238
239
240
241
242
243
244
245
|
# File 'lib/jirametrics/daily_view.rb', line 235
def history_text change:, board:
if change. || change.description?
atlassian_document_format.to_html(change.value)
elsif %w[status priority assignee duedate issuetype].include?(change.field)
field_change_text change, board
elsif change.flagged?
change.value == '' ? 'Off' : 'On'
else
change.value
end
end
|
#issue_sorter ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/jirametrics/daily_view.rb', line 48
def issue_sorter
priority_names = settings['priority_order']
lambda do |a, b|
a_issue, a_priority, a_age = *a
b_issue, b_priority, b_age = *b
a_priority_index = priority_names.index(a_priority)
b_priority_index = priority_names.index(b_priority)
if a_priority_index.nil? && b_priority_index.nil?
result = a_priority <=> b_priority
elsif a_priority_index.nil?
result = 1
elsif b_priority_index.nil?
result = -1
else
result = b_priority_index <=> a_priority_index
end
result = b_age <=> a_age if result.zero?
result = a_issue <=> b_issue if result.zero?
result
end
end
|
#label_lines(issue) ⇒ Object
One 'Labels: ...' and/or 'Components: ...' line, each listing its non-empty collection as label spans.
190
191
192
193
194
195
196
197
|
# File 'lib/jirametrics/daily_view.rb', line 190
def label_lines issue
{ 'Labels:' => issue.labels, 'Components:' => issue.component_names }.filter_map do |label, collection|
next if collection.empty?
spans = collection.collect { |item| "<span class='label'>#{item}</span>" }.join(' ')
"#{label} #{spans}"
end
end
|
#make_blocked_stalled_lines(issue) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/jirametrics/daily_view.rb', line 73
def make_blocked_stalled_lines issue
today = date_range.end
started_date = issue.started_stopped_times.first&.to_date
return [] unless started_date
blocked_stalled = issue.blocked_stalled_by_date(
date_range: today..today, chart_end_time: time_range.end, settings: settings
)[today]
return [] if blocked_stalled.active?
if blocked_stalled.blocked?
blocked_lines blocked_stalled
elsif blocked_stalled.stalled_by_status?
[["#{color_block '--stalled-color'} Stalled by status: #{blocked_stalled.status}"]]
else
[["#{color_block '--stalled-color'} Stalled by inactivity: #{blocked_stalled.stalled_days} days"]]
end
end
|
#make_child_lines(issue) ⇒ Object
199
200
201
202
203
204
205
206
207
208
209
210
|
# File 'lib/jirametrics/daily_view.rb', line 199
def make_child_lines issue
lines = []
subtasks = issue.subtasks
return lines if subtasks.empty?
lines << "<section><div class=\"foldable startFolded\">Child issues (#{subtasks.count})</div>"
lines += subtasks
lines << '</section>'
lines
end
|
#make_description_lines(issue) ⇒ Object
278
279
280
281
282
283
284
285
|
# File 'lib/jirametrics/daily_view.rb', line 278
def make_description_lines issue
description = issue.raw['fields']['description']
return [] unless description
text = "<div class='foldable startFolded'>Description</div>" \
"<div>#{atlassian_document_format.to_html(description)}</div>"
[[text]]
end
|
#make_history_lines(issue) ⇒ Object
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
# File 'lib/jirametrics/daily_view.rb', line 212
def make_history_lines issue
history = issue.changes.reverse
lines = []
lines << '<section><div class="foldable startFolded">Issue history</div>'
table = +''
table << '<table>'
history.each do |c|
time = c.time.strftime '%b %d, %Y @ %I:%M%P'
table << '<tr>'
table << "<td><span class='time' title='Timestamp: #{c.time}'>#{time}</span></td>"
table << "<td><img src='#{c.author_icon_url}' class='icon' title='#{c.author}' /></td>"
text = history_text change: c, board: issue.board
table << "<td><span class='field'>#{c.field_as_human_readable}</span> #{text}</td>"
table << '</tr>'
end
table << '</table>'
lines << [table]
lines << '</section>'
lines
end
|
#make_issue_label(issue:, done:) ⇒ Object
117
118
119
120
121
122
123
|
# File 'lib/jirametrics/daily_view.rb', line 117
def make_issue_label issue:, done:
label = "<img src='#{issue.type_icon_url}' title='#{issue.type}' class='icon' /> "
label << '<s>' if done
label << "<b><a href='#{issue.url}'>#{issue.key}</a></b> <i>#{issue.summary}</i>"
label << '</s>' if done
label
end
|
#make_not_visible_line(issue) ⇒ Object
325
326
327
|
# File 'lib/jirametrics/daily_view.rb', line 325
def make_not_visible_line issue
not_visible_text issue
end
|
#make_parent_lines(issue) ⇒ Object
132
133
134
135
136
137
138
139
140
141
|
# File 'lib/jirametrics/daily_view.rb', line 132
def make_parent_lines issue
lines = []
parent_key = issue.parent_key
if parent_key
parent = issues.find_by_key key: parent_key, include_hidden: true
text = parent ? make_issue_label(issue: parent, done: parent.done?) : parent_key
lines << ["Parent: #{text}"]
end
lines
end
|
#make_sprints_lines(issue) ⇒ Object
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
# File 'lib/jirametrics/daily_view.rb', line 260
def make_sprints_lines issue
return [] unless issue.board.scrum?
sprint_names = issue.sprints.collect do |sprint|
if sprint.closed?
"<s>#{sprint.name}</s>"
else
sprint.name
end
end
return [['Sprints: NONE']] if sprint_names.empty?
[[+'Sprints: ' << sprint_names
.collect { |name| "<span class='label'>#{name}</span>" }
.join(' ')]]
end
|
#make_stats_lines(issue:, done:) ⇒ Object
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
# File 'lib/jirametrics/daily_view.rb', line 143
def make_stats_lines issue:, done:
line = []
line << "<img src='#{issue.priority_url}' class='icon' /> <b>#{issue.priority_name}</b>"
line << progress_line(issue, done)
line << "Status: <b>#{format_status issue.status, board: issue.board}</b>"
column = issue.board.visible_columns.find { |c| c.status_ids.include?(issue.status.id) }
line << "Column: <b>#{column&.name || '(not visible on board)'}</b>"
if issue.assigned_to
line << "Assignee: <img src='#{issue.assigned_to_icon_url}' class='icon' /> <b>#{issue.assigned_to}</b>"
end
due = due_date_line(issue)
line << due if due
line.concat label_lines(issue)
[line]
end
|
#make_title_line(issue:, done:) ⇒ Object
125
126
127
128
129
130
|
# File 'lib/jirametrics/daily_view.rb', line 125
def make_title_line issue:, done:
title_line = +''
title_line << color_block('--expedited-color', title: 'Expedited') if issue.expedited?
title_line << make_issue_label(issue: issue, done: done)
title_line
end
|
#progress_line(issue, done) ⇒ Object
'Cycletime: ...' for finished issues, otherwise 'Age: ...' (or '(Not Started)' when it hasn't started).
164
165
166
167
168
169
170
171
|
# File 'lib/jirametrics/daily_view.rb', line 164
def progress_line issue, done
if done
"Cycletime: <b>#{label_days issue.board.cycletime.cycletime(issue)}</b>"
else
age = issue.board.cycletime.age(issue, today: date_range.end)
"Age: <b>#{age ? label_days(age) : '(Not Started)'}</b>"
end
end
|
#render_issue(issue, child:) ⇒ Object
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
# File 'lib/jirametrics/daily_view.rb', line 305
def render_issue issue, child:
css_class = child ? 'child_issue' : 'daily_issue'
result = +''
result << "<div class='#{css_class}'>"
assemble_issue_lines(issue, child: child).each do |row|
if row.is_a? Issue
result << render_issue(row, child: true)
elsif row.is_a?(String)
result << row
else
result << '<div class="heading">'
row.each do |chunk|
result << "<div>#{chunk}</div>"
end
result << '</div>'
end
end
result << '</div>'
end
|
#run ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/jirametrics/daily_view.rb', line 24
def run
aging_issues = select_aging_issues
if aging_issues.empty?
return "<h1 class='foldable'>#{@header_text}</h1><div>There are no items currently in progress</div>"
end
result = +''
result << render_top_text(binding)
aging_issues.each do |issue|
result << render_issue(issue, child: false)
end
result
end
|
#select_aging_issues ⇒ Object
39
40
41
42
43
44
45
46
|
# File 'lib/jirametrics/daily_view.rb', line 39
def select_aging_issues
aging_issues = issues.select { |issue| issue.board.cycletime.in_progress?(issue) }
today = date_range.end
aging_issues.collect do |issue|
[issue, issue.priority_name, issue.board.cycletime.age(issue, today: today)]
end.sort(&issue_sorter).collect(&:first)
end
|