Module: GroupableIssueChart

Included in:
AgingWorkInProgressChart, CycletimeHistogram, CycletimeScatterplot, ThroughputChart
Defined in:
lib/jirametrics/groupable_issue_chart.rb

Instance Method Summary collapse

Instance Method Details

#group_issues(completed_issues) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/jirametrics/groupable_issue_chart.rb', line 29

def group_issues completed_issues
  result = {}
  completed_issues.each do |issue|
    rules = GroupingRules.new
    @group_by_block.call(issue, rules)
    next if rules.ignored?

    (result[rules] ||= []) << issue
  end

  result.each_key do |rules|
    rules.color = random_color if rules.color.nil?
  end
  result
end

#grouping_rules(&block) ⇒ Object



25
26
27
# File 'lib/jirametrics/groupable_issue_chart.rb', line 25

def grouping_rules &block
  @group_by_block = block
end

#init_configuration_block(user_provided_block, &default_block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/jirametrics/groupable_issue_chart.rb', line 7

def init_configuration_block user_provided_block, &default_block
  # The user provided a block but it's using the old deprecated style
  if user_provided_block && user_provided_block.arity == 1
    deprecated date: '2022-10-02', message: "#{self.class}: Use the new grouping_rules syntax"
    grouping_rules do |issue, rules|
      rules.label, rules.color = user_provided_block.call(issue)
    end
    return
  end

  if user_provided_block
    instance_eval(&user_provided_block)
    return if @group_by_block
  end

  instance_eval(&default_block)
end