jirametrics 2.10 → 2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/jirametrics/aging_work_in_progress_chart.rb +105 -41
- data/lib/jirametrics/aging_work_table.rb +56 -13
- data/lib/jirametrics/atlassian_document_format.rb +156 -0
- data/lib/jirametrics/board.rb +38 -10
- data/lib/jirametrics/board_config.rb +1 -0
- data/lib/jirametrics/board_movement_calculator.rb +155 -0
- data/lib/jirametrics/change_item.rb +38 -16
- data/lib/jirametrics/chart_base.rb +7 -5
- data/lib/jirametrics/css_variable.rb +1 -1
- data/lib/jirametrics/cycletime_config.rb +1 -1
- data/lib/jirametrics/daily_view.rb +274 -0
- data/lib/jirametrics/downloader.rb +61 -21
- data/lib/jirametrics/estimate_accuracy_chart.rb +34 -10
- data/lib/jirametrics/estimation_configuration.rb +25 -0
- data/lib/jirametrics/examples/standard_project.rb +2 -0
- data/lib/jirametrics/exporter.rb +2 -2
- data/lib/jirametrics/file_config.rb +1 -1
- data/lib/jirametrics/flow_efficiency_scatterplot.rb +1 -1
- data/lib/jirametrics/html/aging_work_in_progress_chart.erb +22 -5
- data/lib/jirametrics/html/aging_work_table.erb +7 -3
- data/lib/jirametrics/html/index.css +82 -2
- data/lib/jirametrics/html/index.erb +25 -1
- data/lib/jirametrics/html_report_config.rb +2 -0
- data/lib/jirametrics/issue.rb +69 -28
- data/lib/jirametrics/issue_collection.rb +33 -0
- data/lib/jirametrics/jira_gateway.rb +8 -1
- data/lib/jirametrics/project_config.rb +24 -7
- data/lib/jirametrics/settings.json +2 -1
- data/lib/jirametrics/sprint.rb +1 -0
- data/lib/jirametrics/sprint_burndown.rb +35 -33
- data/lib/jirametrics/sprint_issue_change_data.rb +3 -3
- data/lib/jirametrics/status.rb +3 -0
- data/lib/jirametrics/status_collection.rb +7 -0
- data/lib/jirametrics/user.rb +12 -0
- data/lib/jirametrics.rb +5 -0
- metadata +8 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f219c386b574f433dbaf649b9b7cccc42114401b45ff703a7c8f228c52d815c4
|
|
4
|
+
data.tar.gz: 68af46ec7256e3b4004c4fd8016d52b17b0fa2bb717e9265b164dc5fa59fca56
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 71d289169562b3e4029549ab0db5ef1c4d25bc933d860f6f2a834f6caa39bbb5de93db2932996b7a5d75b4b6fb16f021ac5666cad3d57092dea6b4db4f8b7e97
|
|
7
|
+
data.tar.gz: 425c213d81982d99f9d933d7ad8dbeb4f87f92ec97188d763b51edcb2f7b85a1072da80c0a5df8566a6325223e9b35d98b180e18fd67d1e50cb2d44b1b0e3872
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require 'jirametrics/chart_base'
|
|
4
4
|
require 'jirametrics/groupable_issue_chart'
|
|
5
|
+
require 'jirametrics/board_movement_calculator'
|
|
5
6
|
|
|
6
7
|
class AgingWorkInProgressChart < ChartBase
|
|
7
8
|
include GroupableIssueChart
|
|
@@ -16,13 +17,33 @@ class AgingWorkInProgressChart < ChartBase
|
|
|
16
17
|
This chart shows only work items that have started but not completed, grouped by the column
|
|
17
18
|
they're currently in. Hovering over a dot will show you the ID of that work item.
|
|
18
19
|
</p>
|
|
19
|
-
<
|
|
20
|
-
The
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
<p>
|
|
21
|
+
The shaded areas indicate what percentage of the work has passed that column within that time.
|
|
22
|
+
Notes:
|
|
23
|
+
<ul>
|
|
24
|
+
<li>It only shows columns that are considered "in progress". If you see a column that wouldn't normally
|
|
25
|
+
be thought of that way, then likely issues were moving backwards or continued to progress after hitting
|
|
26
|
+
that column.</li>
|
|
27
|
+
<li>If you see a colour group that drops as it moves to the right, that generally indicates that
|
|
28
|
+
a different number of data points is being included in each column. Probably because tickets moved
|
|
29
|
+
backwards athough it could also indicate that a ticket jumped over columns as it moved to the right.
|
|
30
|
+
</li>
|
|
31
|
+
</ul>
|
|
32
|
+
</p>
|
|
33
|
+
<div style="border: 1px solid gray; padding: 0.2em">
|
|
34
|
+
<% @percentiles.keys.sort.reverse.each do |percent| %>
|
|
35
|
+
<span style="padding-left: 0.5em; padding-right: 0.5em; vertical-align: middle;"><%= color_block @percentiles[percent] %> <%= percent %>%</span>
|
|
36
|
+
<% end %>
|
|
24
37
|
</div>
|
|
25
38
|
HTML
|
|
39
|
+
percentiles(
|
|
40
|
+
50 => '--aging-work-in-progress-chart-shading-50-color',
|
|
41
|
+
85 => '--aging-work-in-progress-chart-shading-85-color',
|
|
42
|
+
98 => '--aging-work-in-progress-chart-shading-98-color',
|
|
43
|
+
100 => '--aging-work-in-progress-chart-shading-100-color'
|
|
44
|
+
)
|
|
45
|
+
show_all_columns false
|
|
46
|
+
|
|
26
47
|
init_configuration_block(block) do
|
|
27
48
|
grouping_rules do |issue, rule|
|
|
28
49
|
rule.label = issue.type
|
|
@@ -36,13 +57,17 @@ class AgingWorkInProgressChart < ChartBase
|
|
|
36
57
|
|
|
37
58
|
@header_text += " on board: #{@all_boards[@board_id].name}"
|
|
38
59
|
data_sets = make_data_sets
|
|
39
|
-
column_headings = @board_columns.collect(&:name)
|
|
40
60
|
|
|
41
|
-
adjust_visibility_of_unmapped_status_column data_sets: data_sets
|
|
61
|
+
adjust_visibility_of_unmapped_status_column data_sets: data_sets
|
|
62
|
+
adjust_chart_height
|
|
42
63
|
|
|
43
64
|
wrap_and_render(binding, __FILE__)
|
|
44
65
|
end
|
|
45
66
|
|
|
67
|
+
def show_all_columns show = true # rubocop:disable Style/OptionalBooleanParameter
|
|
68
|
+
@show_all_columns = show
|
|
69
|
+
end
|
|
70
|
+
|
|
46
71
|
def determine_board_columns
|
|
47
72
|
unmapped_statuses = current_board.possible_statuses.collect(&:id)
|
|
48
73
|
|
|
@@ -51,7 +76,7 @@ class AgingWorkInProgressChart < ChartBase
|
|
|
51
76
|
|
|
52
77
|
@fake_column = BoardColumn.new({
|
|
53
78
|
'name' => '[Unmapped Statuses]',
|
|
54
|
-
'statuses' => unmapped_statuses.collect { |id| { 'id' => id.to_s } }.uniq
|
|
79
|
+
'statuses' => unmapped_statuses.collect { |id| { 'id' => id.to_s } }.uniq # rubocop:disable Performance/ChainArrayAllocation
|
|
55
80
|
})
|
|
56
81
|
@board_columns = columns + [@fake_column]
|
|
57
82
|
end
|
|
@@ -62,7 +87,7 @@ class AgingWorkInProgressChart < ChartBase
|
|
|
62
87
|
board.id == @board_id && board.cycletime.in_progress?(issue)
|
|
63
88
|
end
|
|
64
89
|
|
|
65
|
-
|
|
90
|
+
@max_age = 20
|
|
66
91
|
rules_to_issues = group_issues aging_issues
|
|
67
92
|
data_sets = rules_to_issues.keys.collect do |rules|
|
|
68
93
|
{
|
|
@@ -73,7 +98,10 @@ class AgingWorkInProgressChart < ChartBase
|
|
|
73
98
|
column = column_for issue: issue
|
|
74
99
|
next if column.nil?
|
|
75
100
|
|
|
76
|
-
|
|
101
|
+
@max_age = age if age > @max_age
|
|
102
|
+
|
|
103
|
+
{
|
|
104
|
+
'y' => age,
|
|
77
105
|
'x' => column.name,
|
|
78
106
|
'title' => ["#{issue.key} : #{issue.summary} (#{label_days age})"]
|
|
79
107
|
}
|
|
@@ -83,45 +111,70 @@ class AgingWorkInProgressChart < ChartBase
|
|
|
83
111
|
'backgroundColor' => rules.color
|
|
84
112
|
}
|
|
85
113
|
end
|
|
86
|
-
data_sets << {
|
|
87
|
-
'type' => 'bar',
|
|
88
|
-
'label' => "#{percentage}%",
|
|
89
|
-
'barPercentage' => 1.0,
|
|
90
|
-
'categoryPercentage' => 1.0,
|
|
91
|
-
'backgroundColor' => CssVariable['--aging-work-in-progress-chart-shading-color'],
|
|
92
|
-
'data' => days_at_percentage_threshold_for_all_columns(percentage: percentage, issues: @issues).drop(1)
|
|
93
|
-
}
|
|
94
|
-
end
|
|
95
114
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
115
|
+
calculator = BoardMovementCalculator.new board: @all_boards[@board_id], issues: issues, today: date_range.end
|
|
116
|
+
|
|
117
|
+
column_indexes_to_remove = []
|
|
118
|
+
unless @show_all_columns
|
|
119
|
+
column_indexes_to_remove = indexes_of_leading_and_trailing_zeros(calculator.age_data_for(percentage: 100))
|
|
120
|
+
|
|
121
|
+
column_indexes_to_remove.reverse_each do |index|
|
|
122
|
+
@board_columns.delete_at index
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
@row_index_offset = data_sets.size
|
|
127
|
+
|
|
128
|
+
bar_data = []
|
|
129
|
+
calculator.stacked_age_data_for(percentages: @percentiles.keys).each do |percentage, data|
|
|
130
|
+
column_indexes_to_remove.reverse_each { |index| data.delete_at index }
|
|
131
|
+
color = @percentiles[percentage]
|
|
132
|
+
|
|
133
|
+
data_sets << {
|
|
134
|
+
'type' => 'bar',
|
|
135
|
+
'label' => "#{percentage}%",
|
|
136
|
+
'barPercentage' => 1.0,
|
|
137
|
+
'categoryPercentage' => 1.0,
|
|
138
|
+
'backgroundColor' => color,
|
|
139
|
+
'data' => data
|
|
140
|
+
}
|
|
141
|
+
bar_data << data
|
|
101
142
|
end
|
|
143
|
+
@bar_data = adjust_bar_data bar_data
|
|
144
|
+
|
|
145
|
+
data_sets
|
|
102
146
|
end
|
|
103
147
|
|
|
104
|
-
def
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
148
|
+
def adjust_bar_data input
|
|
149
|
+
return [] if input.empty?
|
|
150
|
+
|
|
151
|
+
row_size = input.first.size
|
|
108
152
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
153
|
+
output = []
|
|
154
|
+
output << input.first
|
|
155
|
+
input.drop(1).each do |row|
|
|
156
|
+
previous_row = output.last
|
|
157
|
+
output << 0.upto(row_size - 1).collect { |i| row[i] + previous_row[i] }
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
output
|
|
112
161
|
end
|
|
113
162
|
|
|
114
|
-
def
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
163
|
+
def indexes_of_leading_and_trailing_zeros list
|
|
164
|
+
result = []
|
|
165
|
+
0.upto(list.size - 1) do |index|
|
|
166
|
+
break unless list[index].zero?
|
|
118
167
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
next if stop < start
|
|
168
|
+
result << index
|
|
169
|
+
end
|
|
122
170
|
|
|
123
|
-
|
|
171
|
+
stop_at = result.empty? ? 0 : (result.last + 1)
|
|
172
|
+
(list.size - 1).downto(stop_at).each do |index|
|
|
173
|
+
break unless list[index].zero?
|
|
174
|
+
|
|
175
|
+
result << index if list[index].zero?
|
|
124
176
|
end
|
|
177
|
+
result
|
|
125
178
|
end
|
|
126
179
|
|
|
127
180
|
def column_for issue:
|
|
@@ -130,7 +183,7 @@ class AgingWorkInProgressChart < ChartBase
|
|
|
130
183
|
end
|
|
131
184
|
end
|
|
132
185
|
|
|
133
|
-
def adjust_visibility_of_unmapped_status_column data_sets
|
|
186
|
+
def adjust_visibility_of_unmapped_status_column data_sets:
|
|
134
187
|
column_name = @fake_column.name
|
|
135
188
|
|
|
136
189
|
has_unmapped = data_sets.any? do |set|
|
|
@@ -143,8 +196,19 @@ class AgingWorkInProgressChart < ChartBase
|
|
|
143
196
|
@description_text += "<p>The items shown in #{column_name.inspect} are not visible on the " \
|
|
144
197
|
'board but are still active. Most likely everyone has forgotten about them.</p>'
|
|
145
198
|
else
|
|
146
|
-
column_headings.pop
|
|
199
|
+
# @column_headings.pop
|
|
147
200
|
@board_columns.pop
|
|
148
201
|
end
|
|
149
202
|
end
|
|
203
|
+
|
|
204
|
+
def percentiles percentile_color_hash
|
|
205
|
+
@percentiles = percentile_color_hash.transform_values { |value| CssVariable[value] }
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def adjust_chart_height
|
|
209
|
+
min_height = @max_age * 5
|
|
210
|
+
|
|
211
|
+
@canvas_height = min_height if min_height > @canvas_height
|
|
212
|
+
@canvas_height = 400 if min_height > 400
|
|
213
|
+
end
|
|
150
214
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require 'jirametrics/chart_base'
|
|
4
4
|
|
|
5
5
|
class AgingWorkTable < ChartBase
|
|
6
|
-
attr_accessor :today
|
|
6
|
+
attr_accessor :today
|
|
7
7
|
attr_reader :any_scrum_boards
|
|
8
8
|
|
|
9
9
|
def initialize block
|
|
@@ -22,18 +22,32 @@ class AgingWorkTable < ChartBase
|
|
|
22
22
|
If there are expedited items that haven't yet started then they're at the bottom of the table.
|
|
23
23
|
By the very definition of expedited, if we haven't started them already, we'd better get on that.
|
|
24
24
|
</p>
|
|
25
|
+
<p>
|
|
26
|
+
Legend:
|
|
27
|
+
<ul>
|
|
28
|
+
<li><b>E:</b> Whether this item is <b>E</b>xpedited.</li>
|
|
29
|
+
<li><b>B/S:</b> Whether this item is either <b>B</b>locked or <b>S</b>talled.</li>
|
|
30
|
+
<li><b>Forecast:</b> A forecast of how long it is likely to take to finish this work item.</li>
|
|
31
|
+
</ul>
|
|
32
|
+
</p>
|
|
25
33
|
TEXT
|
|
26
34
|
|
|
27
35
|
instance_eval(&block)
|
|
28
36
|
end
|
|
29
37
|
|
|
30
38
|
def run
|
|
31
|
-
|
|
39
|
+
initialize_calculator
|
|
32
40
|
aging_issues = select_aging_issues + expedited_but_not_started
|
|
33
41
|
|
|
34
42
|
wrap_and_render(binding, __FILE__)
|
|
35
43
|
end
|
|
36
44
|
|
|
45
|
+
# This is its own method simply so the tests can initialize the calculator without doing a full run.
|
|
46
|
+
def initialize_calculator
|
|
47
|
+
@today = date_range.end
|
|
48
|
+
@calculator = BoardMovementCalculator.new board: current_board, issues: issues, today: @today
|
|
49
|
+
end
|
|
50
|
+
|
|
37
51
|
def expedited_but_not_started
|
|
38
52
|
@issues.select do |issue|
|
|
39
53
|
started_time, stopped_time = issue.board.cycletime.started_stopped_times(issue)
|
|
@@ -94,26 +108,51 @@ class AgingWorkTable < ChartBase
|
|
|
94
108
|
end
|
|
95
109
|
|
|
96
110
|
def sprints_text issue
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
issue.changes.each do |change|
|
|
100
|
-
next unless change.sprint?
|
|
101
|
-
|
|
102
|
-
sprint_ids << change.raw['to'].split(/\s*,\s*/).collect { |id| id.to_i }
|
|
103
|
-
end
|
|
104
|
-
sprint_ids.flatten!
|
|
105
|
-
|
|
106
|
-
issue.board.sprints.select { |s| sprint_ids.include? s.id }.collect do |sprint|
|
|
111
|
+
issue.sprints.collect do |sprint|
|
|
107
112
|
icon_text = nil
|
|
108
113
|
if sprint.active?
|
|
109
114
|
icon_text = icon_span title: 'Active sprint', icon: '➡️'
|
|
110
|
-
|
|
115
|
+
elsif sprint.closed?
|
|
111
116
|
icon_text = icon_span title: 'Sprint closed', icon: '✅'
|
|
112
117
|
end
|
|
113
118
|
"#{sprint.name} #{icon_text}"
|
|
114
119
|
end.join('<br />')
|
|
115
120
|
end
|
|
116
121
|
|
|
122
|
+
def dates_text issue
|
|
123
|
+
date = date_range.end
|
|
124
|
+
due = issue.due_date
|
|
125
|
+
message = nil
|
|
126
|
+
|
|
127
|
+
days_remaining, error = @calculator.forecasted_days_remaining_and_message issue: issue, today: @today
|
|
128
|
+
|
|
129
|
+
unless error
|
|
130
|
+
if due
|
|
131
|
+
if due < date
|
|
132
|
+
message = "Due: <b>#{due}</b> (#{label_days (@today - due).to_i} ago)"
|
|
133
|
+
error = 'Overdue'
|
|
134
|
+
elsif due == date
|
|
135
|
+
message = 'Due: <b>today</b>'
|
|
136
|
+
else
|
|
137
|
+
error = 'Due date at risk' if date_range.end + days_remaining > due
|
|
138
|
+
message = "Due: <b>#{due}</b> (#{label_days (due - @today).to_i})"
|
|
139
|
+
end
|
|
140
|
+
else
|
|
141
|
+
"#{label_days days_remaining} left."
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
text = +''
|
|
146
|
+
text << "<span title='#{error}' style='color: red'>ⓘ </span>" if error
|
|
147
|
+
if days_remaining
|
|
148
|
+
text << "#{label_days days_remaining} left"
|
|
149
|
+
else
|
|
150
|
+
text << 'Unable to forecast'
|
|
151
|
+
end
|
|
152
|
+
text << ' | ' << message if message
|
|
153
|
+
text
|
|
154
|
+
end
|
|
155
|
+
|
|
117
156
|
def age_cutoff age = nil
|
|
118
157
|
@age_cutoff = age.to_i if age
|
|
119
158
|
@age_cutoff
|
|
@@ -133,4 +172,8 @@ class AgingWorkTable < ChartBase
|
|
|
133
172
|
|
|
134
173
|
result.reverse
|
|
135
174
|
end
|
|
175
|
+
|
|
176
|
+
def priority_text issue
|
|
177
|
+
"<img src='#{issue.priority_url}' title='Priority: #{issue.priority_name}' />"
|
|
178
|
+
end
|
|
136
179
|
end
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class AtlassianDocumentFormat
|
|
4
|
+
attr_reader :users
|
|
5
|
+
|
|
6
|
+
def initialize users:, timezone_offset:
|
|
7
|
+
@users = users
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def to_html input
|
|
11
|
+
if input.is_a? String
|
|
12
|
+
input
|
|
13
|
+
.gsub(/{color:(#\w{6})}([^{]+){color}/, '<span style="color: \1">\2</span>') # Colours
|
|
14
|
+
.gsub(/\[~accountid:([^\]]+)\]/) { expand_account_id $1 } # Tagged people
|
|
15
|
+
.gsub(/\[([^\|]+)\|(https?[^\]]+)\]/, '<a href="\2">\1</a>') # URLs
|
|
16
|
+
.gsub("\n", '<br />')
|
|
17
|
+
else
|
|
18
|
+
input['content'].collect { |element| adf_node_to_html element }.join("\n")
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# ADF is Atlassian Document Format
|
|
23
|
+
# https://developer.atlassian.com/cloud/jira/platform/apis/document/structure/
|
|
24
|
+
def adf_node_to_html node
|
|
25
|
+
closing_tag = nil
|
|
26
|
+
node_attrs = node['attrs']
|
|
27
|
+
|
|
28
|
+
result = +''
|
|
29
|
+
case node['type']
|
|
30
|
+
when 'blockquote'
|
|
31
|
+
result << '<blockquote>'
|
|
32
|
+
closing_tag = '</blockquote>'
|
|
33
|
+
when 'bulletList'
|
|
34
|
+
result << '<ul>'
|
|
35
|
+
closing_tag = '</ul>'
|
|
36
|
+
when 'codeBlock'
|
|
37
|
+
result << '<code>'
|
|
38
|
+
closing_tag = '</code>'
|
|
39
|
+
when 'date'
|
|
40
|
+
result << Time.at(node_attrs['timestamp'].to_i / 1000, in: @timezone_offset).to_date.to_s
|
|
41
|
+
when 'decisionItem'
|
|
42
|
+
result << '<li>'
|
|
43
|
+
closing_tag = '</li>'
|
|
44
|
+
when 'decisionList'
|
|
45
|
+
result << '<div>Decisions<ul>'
|
|
46
|
+
closing_tag = '</ul></div>'
|
|
47
|
+
when 'emoji'
|
|
48
|
+
result << node_attrs['text']
|
|
49
|
+
when 'expand'
|
|
50
|
+
# TODO: Maybe, someday, make this actually expandable. For now it's always open
|
|
51
|
+
result << "<div>#{node_attrs['title']}</div>"
|
|
52
|
+
when 'hardBreak'
|
|
53
|
+
result << '<br />'
|
|
54
|
+
when 'heading'
|
|
55
|
+
level = node_attrs['level']
|
|
56
|
+
result << "<h#{level}>"
|
|
57
|
+
closing_tag = "</h#{level}>"
|
|
58
|
+
when 'inlineCard'
|
|
59
|
+
url = node_attrs['url']
|
|
60
|
+
result << "[Inline card]: <a href='#{url}'>#{url}</a>"
|
|
61
|
+
when 'listItem'
|
|
62
|
+
result << '<li>'
|
|
63
|
+
closing_tag = '</li>'
|
|
64
|
+
when 'media'
|
|
65
|
+
text = node_attrs['alt'] || node_attrs['id']
|
|
66
|
+
result << "Media: #{text}"
|
|
67
|
+
when 'mediaSingle', 'mediaGroup'
|
|
68
|
+
result << '<div>'
|
|
69
|
+
closing_tag = '</div>'
|
|
70
|
+
when 'mention'
|
|
71
|
+
user = node_attrs['text']
|
|
72
|
+
result << "<b>#{user}</b>"
|
|
73
|
+
when 'orderedList'
|
|
74
|
+
result << '<ol>'
|
|
75
|
+
closing_tag = '</ol>'
|
|
76
|
+
when 'panel'
|
|
77
|
+
type = node_attrs['panelType']
|
|
78
|
+
result << "<div>#{type.upcase}</div>"
|
|
79
|
+
when 'paragraph'
|
|
80
|
+
result << '<p>'
|
|
81
|
+
closing_tag = '</p>'
|
|
82
|
+
when 'rule'
|
|
83
|
+
result << '<hr />'
|
|
84
|
+
when 'status'
|
|
85
|
+
text = node_attrs['text']
|
|
86
|
+
result << text
|
|
87
|
+
when 'table'
|
|
88
|
+
result << '<table>'
|
|
89
|
+
closing_tag = '</table>'
|
|
90
|
+
when 'tableCell'
|
|
91
|
+
result << '<td>'
|
|
92
|
+
closing_tag = '</td>'
|
|
93
|
+
when 'tableHeader'
|
|
94
|
+
result << '<th>'
|
|
95
|
+
closing_tag = '</th>'
|
|
96
|
+
when 'tableRow'
|
|
97
|
+
result << '<tr>'
|
|
98
|
+
closing_tag = '</tr>'
|
|
99
|
+
when 'text'
|
|
100
|
+
marks = adf_marks_to_html node['marks']
|
|
101
|
+
result << marks.collect(&:first).join
|
|
102
|
+
result << node['text']
|
|
103
|
+
result << marks.collect(&:last).join
|
|
104
|
+
when 'taskItem'
|
|
105
|
+
state = node_attrs['state'] == 'TODO' ? '☐' : '☑'
|
|
106
|
+
result << "<li>#{state} "
|
|
107
|
+
closing_tag = '</li>'
|
|
108
|
+
when 'taskList'
|
|
109
|
+
result << "<ul class='taskList'>"
|
|
110
|
+
closing_tag = '</ul>'
|
|
111
|
+
else
|
|
112
|
+
result << "<p>Unparseable section: #{node['type']}</p>"
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
node['content']&.each do |child|
|
|
116
|
+
result << adf_node_to_html(child)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
result << closing_tag if closing_tag
|
|
120
|
+
result
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def adf_marks_to_html list
|
|
124
|
+
return [] if list.nil?
|
|
125
|
+
|
|
126
|
+
mappings = [
|
|
127
|
+
['strong', '<b>', '</b>'],
|
|
128
|
+
['code', '<code>', '</code>'],
|
|
129
|
+
['em', '<em>', '</em>'],
|
|
130
|
+
['strike', '<s>', '</s>'],
|
|
131
|
+
['underline', '<u>', '</u>']
|
|
132
|
+
]
|
|
133
|
+
|
|
134
|
+
list.filter_map do |mark|
|
|
135
|
+
type = mark['type']
|
|
136
|
+
if type == 'textColor'
|
|
137
|
+
color = mark['attrs']['color']
|
|
138
|
+
["<span style='color: #{color}'>", '</span>']
|
|
139
|
+
elsif type == 'link'
|
|
140
|
+
href = mark['attrs']['href']
|
|
141
|
+
title = mark['attrs']['title']
|
|
142
|
+
["<a href='#{href}' title='#{title}'>", '</a>']
|
|
143
|
+
else
|
|
144
|
+
line = mappings.find { |key, _open, _close| key == type }
|
|
145
|
+
[line[1], line[2]] if line
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def expand_account_id account_id
|
|
151
|
+
user = @users.find { |u| u.account_id == account_id }
|
|
152
|
+
text = account_id
|
|
153
|
+
text = "@#{user.display_name}" if user
|
|
154
|
+
"<span class='account_id'>#{text}</span>"
|
|
155
|
+
end
|
|
156
|
+
end
|
data/lib/jirametrics/board.rb
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class Board
|
|
4
|
-
attr_reader :visible_columns, :raw, :possible_statuses, :sprints
|
|
4
|
+
attr_reader :visible_columns, :raw, :possible_statuses, :sprints
|
|
5
5
|
attr_accessor :cycletime, :project_config
|
|
6
6
|
|
|
7
7
|
def initialize raw:, possible_statuses:
|
|
8
8
|
@raw = raw
|
|
9
|
-
@board_type = raw['type']
|
|
10
9
|
@possible_statuses = possible_statuses
|
|
11
10
|
@sprints = []
|
|
12
11
|
|
|
13
12
|
columns = raw['columnConfig']['columns']
|
|
13
|
+
ensure_uniqueness_of_column_names! columns
|
|
14
14
|
|
|
15
15
|
# For a Kanban board, the first column here will always be called 'Backlog' and will NOT be
|
|
16
16
|
# visible on the board. If the board is configured to have a kanban backlog then it will have
|
|
17
17
|
# statuses matched to it and otherwise, there will be no statuses.
|
|
18
|
-
columns = columns
|
|
18
|
+
columns = columns.drop(1) if kanban?
|
|
19
19
|
|
|
20
20
|
@backlog_statuses = []
|
|
21
21
|
@visible_columns = columns.filter_map do |column|
|
|
@@ -66,13 +66,9 @@ class Board
|
|
|
66
66
|
status_ids
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
def
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
def scrum?
|
|
74
|
-
@board_type == 'scrum'
|
|
75
|
-
end
|
|
69
|
+
def board_type = raw['type']
|
|
70
|
+
def kanban? = (board_type == 'kanban')
|
|
71
|
+
def scrum? = (board_type == 'scrum')
|
|
76
72
|
|
|
77
73
|
def id
|
|
78
74
|
@raw['id'].to_i
|
|
@@ -88,4 +84,36 @@ class Board
|
|
|
88
84
|
def name
|
|
89
85
|
@raw['name']
|
|
90
86
|
end
|
|
87
|
+
|
|
88
|
+
def accumulated_status_ids_per_column
|
|
89
|
+
accumulated_status_ids = []
|
|
90
|
+
visible_columns.reverse.filter_map do |column|
|
|
91
|
+
next if column == @fake_column
|
|
92
|
+
|
|
93
|
+
accumulated_status_ids += column.status_ids
|
|
94
|
+
[column.name, accumulated_status_ids.dup]
|
|
95
|
+
end.reverse
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def ensure_uniqueness_of_column_names! json
|
|
99
|
+
all_names = []
|
|
100
|
+
json.each do |column_json|
|
|
101
|
+
name = column_json['name']
|
|
102
|
+
if all_names.include? name
|
|
103
|
+
(2..).each do |i|
|
|
104
|
+
new_name = "#{name}-#{i}"
|
|
105
|
+
next if all_names.include?(new_name)
|
|
106
|
+
|
|
107
|
+
name = new_name
|
|
108
|
+
column_json['name'] = new_name
|
|
109
|
+
break
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
all_names << name
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def estimation_configuration
|
|
117
|
+
EstimationConfiguration.new raw: raw['estimation']
|
|
118
|
+
end
|
|
91
119
|
end
|