Class: DailyWipChart
Instance Attribute Summary collapse
Attributes inherited from ChartBase
#aggregated_project, #all_boards, #board_id, #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
#initialize(block = nil) ⇒ DailyWipChart
Returns a new instance of DailyWipChart.
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/jirametrics/daily_wip_chart.rb', line 17
def initialize block = nil
super()
description_text default_description_text
if block
instance_eval(&block)
else
grouping_rules do |issue, rules|
default_grouping_rules issue: issue, rules: rules
end
end
end
|
Instance Attribute Details
#possible_statuses ⇒ Object
Returns the value of attribute possible_statuses.
15
16
17
|
# File 'lib/jirametrics/daily_wip_chart.rb', line 15
def possible_statuses
@possible_statuses
end
|
Instance Method Details
111
112
113
114
115
116
117
118
|
# File 'lib/jirametrics/daily_wip_chart.rb', line 111
def configure_rule issue:, date:
raise 'grouping_rules must be set' if @group_by_block.nil?
rules = DailyGroupingRules.new
rules.current_date = date
@group_by_block.call issue, rules
rules
end
|
#default_description_text ⇒ Object
44
|
# File 'lib/jirametrics/daily_wip_chart.rb', line 44
def default_description_text = ''
|
#default_grouping_rules(issue:, rules:) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
46
47
48
|
# File 'lib/jirametrics/daily_wip_chart.rb', line 46
def default_grouping_rules issue:, rules: raise 'If you use this class directly then you must provide grouping_rules'
end
|
43
|
# File 'lib/jirametrics/daily_wip_chart.rb', line 43
def = 'Daily WIP'
|
#group_issues_by_active_dates ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/jirametrics/daily_wip_chart.rb', line 60
def group_issues_by_active_dates
hash = {}
@issues.each do |issue|
cycletime = issue.board.cycletime
start = cycletime.started_time(issue)&.to_date
stop = cycletime.stopped_time(issue)&.to_date
next if start.nil? && stop.nil?
start = issue.created.to_date if stop && start.nil?
start = @date_range.begin if start < @date_range.begin
start.upto(stop || @date_range.end) do |date|
rule = configure_rule issue: issue, date: date
(hash[date] ||= []) << [issue, rule] unless rule.ignored?
end
end
hash
end
|
#grouping_rules(&block) ⇒ Object
120
121
122
|
# File 'lib/jirametrics/daily_wip_chart.rb', line 120
def grouping_rules &block
@group_by_block = block
end
|
#make_data_set(grouping_rule:, issue_rules_by_active_date:) ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/jirametrics/daily_wip_chart.rb', line 82
def make_data_set grouping_rule:, issue_rules_by_active_date:
positive = grouping_rule.group_priority >= 0
data = issue_rules_by_active_date.collect do |date, issue_rules|
issue_strings = issue_rules
.select { |_issue, rules| rules.group == grouping_rule.group }
.sort_by { |issue, _rules| issue.key_as_i }
.collect { |issue, rules| "#{issue.key} : #{issue.summary.strip} #{rules.issue_hint}" }
title = ["#{grouping_rule.label} (#{label_issues issue_strings.size})"] + issue_strings
{
x: date,
y: positive ? issue_strings.size : -issue_strings.size,
title: title
}
end
{
type: 'bar',
label: grouping_rule.label,
data: data,
backgroundColor: grouping_rule.color || random_color,
borderColor: 'gray',
borderWidth: grouping_rule.color == 'white' ? 1 : 0,
borderRadius: positive ? 0 : 5
}
end
|
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/jirametrics/daily_wip_chart.rb', line 32
def run
issue_rules_by_active_date = group_issues_by_active_dates
possible_rules = select_possible_rules issue_rules_by_active_date
data_sets = possible_rules.collect do |grouping_rule|
make_data_set grouping_rule: grouping_rule, issue_rules_by_active_date: issue_rules_by_active_date
end
wrap_and_render(binding, __FILE__)
end
|
#select_possible_rules(issue_rules_by_active_date) ⇒ Object
50
51
52
53
54
55
56
57
58
|
# File 'lib/jirametrics/daily_wip_chart.rb', line 50
def select_possible_rules issue_rules_by_active_date
possible_rules = []
issue_rules_by_active_date.each_pair do |_date, issues_rules_list|
issues_rules_list.each do |_issue, rules|
possible_rules << rules unless possible_rules.any? { |r| r.group == rules.group }
end
end
possible_rules.sort_by!(&:group_priority)
end
|