Module: Bicho::Reports

Defined in:
lib/bicho/reports.rb

Overview

Utility methods for reporting on bugs

Class Method Summary collapse

Class Method Details

.ranges_with_statuses(bug, *statuses) ⇒ Object

returns the ranges a bug is with statuses



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/bicho/reports.rb', line 21

def self.ranges_with_statuses(bug, *statuses)
  ranges = []
  current_start = bug.creation_time
  current_status = nil
  bug.history.sort_by(&:timestamp).each do |cs|
    cs.changes.each do |c|
      next unless c.field_name == 'status'

      current_status = c.removed if current_status.nil?
      ranges.push(current_start..cs.timestamp) if statuses.include?(c.removed)

      current_start = cs.timestamp
      current_status = c.added
    end
  end
  # last status is still valid
  ranges.push(current_start..Time.now) if statuses.include?(current_status)
  ranges
end

.resolution_time(bug) ⇒ Object

When was the bug finally set to a resolved state

Resolution time is nil if the bug is not resolved yet.



9
10
11
12
13
14
15
16
17
18
# File 'lib/bicho/reports.rb', line 9

def self.resolution_time(bug)
  t = nil
  bug.history.sort_by(&:timestamp).each do |cs|
    cs.changes.each do |c|
      t = cs.timestamp if c.field_name == 'status' &&
                          c.added == 'RESOLVED'
    end
  end
  t
end