Class: Shiftzilla::ReleaseData

Inherits:
Object
  • Object
show all
Defined in:
lib/shiftzilla/release_data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(release) ⇒ ReleaseData

Returns a new instance of ReleaseData.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/shiftzilla/release_data.rb', line 8

def initialize(release)
  @release         = release
  @snaps           = {}
  @bugs            = {}
  @prev_snap       = nil
  @latest_snap     = nil
  @latest_snapdate = nil
  @first_snap      = nil
  @first_snapdate  = nil
  @labels          = {}
  @series          = {
    :date        => [],
    :ideal       => [],
    :total_bugs  => [],
    :new_bugs    => [],
    :closed_bugs => [],
    :total_tb    => [],
    :new_tb      => [],
    :closed_tb   => [],
    :total_cc    => [],
    :new_cc      => [],
    :closed_cc   => [],
  }
end

Instance Attribute Details

#bugsObject

Returns the value of attribute bugs.



6
7
8
# File 'lib/shiftzilla/release_data.rb', line 6

def bugs
  @bugs
end

#first_snapObject

Returns the value of attribute first_snap.



6
7
8
# File 'lib/shiftzilla/release_data.rb', line 6

def first_snap
  @first_snap
end

#first_snapdateObject

Returns the value of attribute first_snapdate.



6
7
8
# File 'lib/shiftzilla/release_data.rb', line 6

def first_snapdate
  @first_snapdate
end

#labelsObject

Returns the value of attribute labels.



6
7
8
# File 'lib/shiftzilla/release_data.rb', line 6

def labels
  @labels
end

#latest_snapObject

Returns the value of attribute latest_snap.



6
7
8
# File 'lib/shiftzilla/release_data.rb', line 6

def latest_snap
  @latest_snap
end

#latest_snapdateObject

Returns the value of attribute latest_snapdate.



6
7
8
# File 'lib/shiftzilla/release_data.rb', line 6

def latest_snapdate
  @latest_snapdate
end

#prev_snapObject

Returns the value of attribute prev_snap.



6
7
8
# File 'lib/shiftzilla/release_data.rb', line 6

def prev_snap
  @prev_snap
end

#seriesObject

Returns the value of attribute series.



6
7
8
# File 'lib/shiftzilla/release_data.rb', line 6

def series
  @series
end

#snapsObject

Returns the value of attribute snaps.



6
7
8
# File 'lib/shiftzilla/release_data.rb', line 6

def snaps
  @snaps
end

Instance Method Details

#add_or_update_bug(bzid, binfo) ⇒ Object



141
142
143
144
145
146
147
148
# File 'lib/shiftzilla/release_data.rb', line 141

def add_or_update_bug(bzid,binfo)
  unless @bugs.has_key?(bzid)
    @bugs[bzid] = Shiftzilla::Bug.new(bzid,binfo)
  else
    @bugs[bzid].update(binfo)
  end
  @bugs[bzid]
end

#bug_avg_age(blockers_only = false) ⇒ Object



119
120
121
122
123
124
# File 'lib/shiftzilla/release_data.rb', line 119

def bug_avg_age(blockers_only=false)
  bug_list  = blockers_only ? @bugs.values.select{ |b| b.test_blocker } : @bugs.values
  bug_count = bug_list.length
  age_total = bug_list.map{ |b| b.age }.sum
  return bug_count == 0 ? 0 : (age_total / bug_count).round(1).to_s
end

#burndown_spanObject



110
111
112
113
114
115
116
117
# File 'lib/shiftzilla/release_data.rb', line 110

def burndown_span
  if @release.uses_milestones?
    return business_days_between(@release.milestones.start.date,@release.milestones.code_freeze.date) - 2
  elsif not @first_snapdate.nil? and not @latest_snapdate.nil?
    return business_days_between(@first_snapdate,@latest_snapdate)
  end
  return nil
end

#get_snapdata(snapshot) ⇒ Object



134
135
136
137
138
139
# File 'lib/shiftzilla/release_data.rb', line 134

def get_snapdata(snapshot)
  unless @snaps.has_key?(snapshot)
    @snaps[snapshot] = Shiftzilla::SnapData.new(snapshot)
  end
  @snaps[snapshot]
end

#has_snapdata?(snapshot) ⇒ Boolean

Returns:



130
131
132
# File 'lib/shiftzilla/release_data.rb', line 130

def has_snapdata?(snapshot)
  @snaps.has_key?(snapshot)
end

#max_ccObject



50
51
52
53
54
55
# File 'lib/shiftzilla/release_data.rb', line 50

def max_cc
  pick_max([@snaps.values.map{ |s| s.total_cc },
            @snaps.values.map{ |s| s.new_cc },
            @snaps.values.map{ |s| s.closed_cc }
          ])
end

#max_new_closedObject



37
38
39
40
41
# File 'lib/shiftzilla/release_data.rb', line 37

def max_new_closed
  pick_max([@snaps.values.map{ |s| s.new_bugs },
            @snaps.values.map{ |s| s.closed_bugs }
          ])
end

#max_tbObject



43
44
45
46
47
48
# File 'lib/shiftzilla/release_data.rb', line 43

def max_tb
  pick_max([@snaps.values.map{ |s| s.total_tb },
            @snaps.values.map{ |s| s.new_tb },
            @snaps.values.map{ |s| s.closed_tb }
          ])
end

#max_totalObject



33
34
35
# File 'lib/shiftzilla/release_data.rb', line 33

def max_total
  pick_max([@snaps.values.map{ |s| s.total_bugs }])
end

#populate_seriesObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/shiftzilla/release_data.rb', line 57

def populate_series
  return if first_snap.nil?

  # Set up the 'ideal' series
  ideal_slope = max_total.to_f / burndown_span.to_f
  ideal_total = max_total

  range_idx = 0
  series_range.each do |date|
    next if date.saturday? or date.sunday?
    snapshot = date.strftime('%Y-%m-%d')

    @series[:date] << snapshot
    @series[:ideal] << ideal_total
    ideal_total = ideal_total < ideal_slope ? 0 : ideal_total - ideal_slope

    snapdata = @snaps.has_key?(snapshot) ? @snaps[snapshot] : nil
    if date < first_snapdate
      snapdata = @snaps[first_snap]
    end

    ['bugs','tb','cc'].each do |set|
      ['total','new','closed'].each do |count|
        set_key = "#{count}_#{set}".to_sym
        @series[set_key] << (snapdata.nil? ? nil : snapdata.send(set_key))
      end
    end

    if range_idx % label_modulo == 0
      @labels[range_idx] = date.strftime('%m/%d')
    end
    range_idx += 1
  end
end

#series_rangeObject



92
93
94
95
96
97
98
99
# File 'lib/shiftzilla/release_data.rb', line 92

def series_range
  if @release.uses_milestones?
    return (@release.milestones.start.date..@release.milestones.ga.date)
  elsif not @first_snapdate.nil? and not @latest_snapdate.nil?
    return (@first_snapdate..@latest_snapdate)
  end
  return nil
end

#series_spanObject



101
102
103
104
105
106
107
108
# File 'lib/shiftzilla/release_data.rb', line 101

def series_span
  if @release.uses_milestones?
    return business_days_between(@release.milestones.start.date,@release.milestones.ga.date)
  elsif not @first_snapdate.nil? and not @latest_snapdate.nil?
    return business_days_between(@first_snapdate,@latest_snapdate)
  end
  return nil
end

#tb_avg_ageObject



126
127
128
# File 'lib/shiftzilla/release_data.rb', line 126

def tb_avg_age
  bug_avg_age(true)
end