Class: Shiftzilla::ReleaseData
- Inherits:
-
Object
- Object
- Shiftzilla::ReleaseData
- Defined in:
- lib/shiftzilla/release_data.rb
Instance Attribute Summary collapse
-
#bugs ⇒ Object
Returns the value of attribute bugs.
-
#first_snap ⇒ Object
Returns the value of attribute first_snap.
-
#first_snapdate ⇒ Object
Returns the value of attribute first_snapdate.
-
#labels ⇒ Object
Returns the value of attribute labels.
-
#latest_snap ⇒ Object
Returns the value of attribute latest_snap.
-
#latest_snapdate ⇒ Object
Returns the value of attribute latest_snapdate.
-
#prev_snap ⇒ Object
Returns the value of attribute prev_snap.
-
#series ⇒ Object
Returns the value of attribute series.
-
#snaps ⇒ Object
Returns the value of attribute snaps.
Instance Method Summary collapse
- #add_or_update_bug(bzid, binfo) ⇒ Object
- #bug_avg_age(blockers_only = false) ⇒ Object
- #burndown_span ⇒ Object
- #get_snapdata(snapshot) ⇒ Object
- #has_snapdata?(snapshot) ⇒ Boolean
-
#initialize(release) ⇒ ReleaseData
constructor
A new instance of ReleaseData.
- #max_cc ⇒ Object
- #max_new_closed ⇒ Object
- #max_tb ⇒ Object
- #max_total ⇒ Object
- #populate_series ⇒ Object
- #series_range ⇒ Object
- #series_span ⇒ Object
- #tb_avg_age ⇒ Object
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
#bugs ⇒ Object
Returns the value of attribute bugs.
6 7 8 |
# File 'lib/shiftzilla/release_data.rb', line 6 def bugs @bugs end |
#first_snap ⇒ Object
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_snapdate ⇒ Object
Returns the value of attribute first_snapdate.
6 7 8 |
# File 'lib/shiftzilla/release_data.rb', line 6 def first_snapdate @first_snapdate end |
#labels ⇒ Object
Returns the value of attribute labels.
6 7 8 |
# File 'lib/shiftzilla/release_data.rb', line 6 def labels @labels end |
#latest_snap ⇒ Object
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_snapdate ⇒ Object
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_snap ⇒ Object
Returns the value of attribute prev_snap.
6 7 8 |
# File 'lib/shiftzilla/release_data.rb', line 6 def prev_snap @prev_snap end |
#series ⇒ Object
Returns the value of attribute series.
6 7 8 |
# File 'lib/shiftzilla/release_data.rb', line 6 def series @series end |
#snaps ⇒ Object
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_span ⇒ Object
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
130 131 132 |
# File 'lib/shiftzilla/release_data.rb', line 130 def has_snapdata?(snapshot) @snaps.has_key?(snapshot) end |
#max_cc ⇒ Object
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_closed ⇒ Object
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_tb ⇒ Object
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_total ⇒ Object
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_series ⇒ Object
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_range ⇒ Object
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_span ⇒ Object
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_age ⇒ Object
126 127 128 |
# File 'lib/shiftzilla/release_data.rb', line 126 def tb_avg_age bug_avg_age(true) end |