Class: Shiftzilla::OrgData
- Inherits:
-
Object
- Object
- Shiftzilla::OrgData
- Defined in:
- lib/shiftzilla/org_data.rb
Instance Attribute Summary collapse
-
#tmp_dir ⇒ Object
readonly
Returns the value of attribute tmp_dir.
Instance Method Summary collapse
- #build_series ⇒ Object
- #generate_reports ⇒ Object
- #get_ordered_teams ⇒ Object
- #get_release_data(team_name, release) ⇒ Object
-
#initialize(config) ⇒ OrgData
constructor
A new instance of OrgData.
- #populate_releases ⇒ Object
- #publish_reports(ssh) ⇒ Object
- #show_local_reports ⇒ Object
Constructor Details
#initialize(config) ⇒ OrgData
Returns a new instance of OrgData.
12 13 14 15 16 17 18 |
# File 'lib/shiftzilla/org_data.rb', line 12 def initialize(config) @config = config @teams = config.teams @releases = config.releases @tmp_dir = Shiftzilla::Helpers.tmp_dir @org_data = { '_overall' => Shiftzilla::TeamData.new('_overall') } end |
Instance Attribute Details
#tmp_dir ⇒ Object (readonly)
Returns the value of attribute tmp_dir.
10 11 12 |
# File 'lib/shiftzilla/org_data.rb', line 10 def tmp_dir @tmp_dir end |
Instance Method Details
#build_series ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/shiftzilla/org_data.rb', line 147 def build_series @team_files = [] @ordered_teams.each do |tname| unless @org_data.has_key?(tname) @org_data[tname] = Shiftzilla::TeamData.new(tname) end tdata = @org_data[tname] tinfo = @config.team(tname) @team_files << { :tname => tdata.title, :file => tdata.file, :releases => {}, } @releases.each do |release| rname = release.name bug_total = 0 unless tdata.has_release_data?(release) @team_files[-1][:releases][release.name] = bug_total next end rdata = tdata.get_release_data(release) if rdata.snaps.has_key?(latest_snapshot) bug_total = rdata.snaps[latest_snapshot].total_bugs end @team_files[-1][:releases][release.name] = bug_total next if rdata.first_snap.nil? and not release.uses_milestones? next if release.built_in? rdata.populate_series end end end |
#generate_reports ⇒ Object
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/shiftzilla/org_data.rb', line 183 def generate_reports build_time = all_release = @config.release('All') @ordered_teams.each do |tname| tinfo = @config.team(tname) tdata = @org_data[tname] team_pinfo = { :build_time => build_time, :tdisp => tdata.title, :tname => tdata.name, :tinfo => tinfo, :tdata => tdata, :team_files => @team_files, :bug_url => BZ_URL, :releases => [], :latest_snapshot => latest_snapshot, :all_bugs => [], } @releases.each do |release| rname = release.name rdata = tdata.has_release_data?(release) ? tdata.get_release_data(release) : nil snapdata = nil if not rdata.nil? and rdata.snaps.has_key?(latest_snapshot) snapdata = rdata.snaps[latest_snapshot] else snapdata = Shiftzilla::SnapData.new(latest_snapshot) end release_info = { :release => release, :snapdata => snapdata, :no_rdata => (rdata.nil? ? true : false), :bug_avg_age => (rdata.nil? ? 0 : rdata.bug_avg_age), :tb_avg_age => (rdata.nil? ? 0 : rdata.tb_avg_age), } unless rdata.nil? release_info[:charts] = { :burndown => chartify('Bug Burndown',rdata.series[:date],[ { :label => 'Ideal Trend', :data => rdata.series[:ideal], }, { :label => 'Total', :data => rdata.series[:total_bugs], }, { :label => 'w/ Customer Cases', :data => rdata.series[:total_cc], }, ]), :new_closed => chartify('New vs. Closed',rdata.series[:date],[ { :label => 'New', :data => rdata.series[:new_bugs], }, { :label => 'Closed', :data => rdata.series[:closed_bugs], }, ]), :blockers => chartify('Test / Ops Blockers',rdata.series[:date],[ { :label => 'Total', :data => rdata.series[:total_tb], }, { :label => 'New', :data => rdata.series[:new_tb], }, { :label => 'Closed', :data => rdata.series[:closed_tb], }, ]), } end team_pinfo[:releases] << release_info if rname == 'All' team_pinfo[:all_bugs] = snapdata.bug_ids.map{ |id| rdata.bugs[id] } end end team_page = haml_engine.render(Object.new,team_pinfo) File.write(File.join(@tmp_dir,tdata.file), team_page) end # Copy flot library to build area jsdir = File.join(@tmp_dir,'js') Dir.mkdir(jsdir) FileUtils.cp(File.join(VENDOR_DIR,'flot','jquery.flot.min.js'),jsdir) FileUtils.cp(DB_FPATH,@tmp_dir) end |
#get_ordered_teams ⇒ Object
136 137 138 |
# File 'lib/shiftzilla/org_data.rb', line 136 def get_ordered_teams @ordered_teams end |
#get_release_data(team_name, release) ⇒ Object
140 141 142 143 144 145 |
# File 'lib/shiftzilla/org_data.rb', line 140 def get_release_data(team_name,release) if @org_data.has_key?(team_name) and @org_data[team_name].has_release_data?(release) return @org_data[team_name].get_release_data(release) end return nil end |
#populate_releases ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/shiftzilla/org_data.rb', line 20 def populate_releases all_snapshots.each do |snapshot| snapdate = Date.parse(snapshot) next if snapdate < @config.earliest_milestone break if snapdate > @config.latest_milestone break if snapdate > Date.today dbh.execute(all_bugs_query(snapshot)) do |row| bzid = row[0].strip comp = row[1].strip tgtr = row[2].strip owns = row[3].strip stat = row[4].strip summ = row[5].strip keyw = row[6].nil? ? '' : row[6].strip pmsc = row[7].nil? ? '0' : row[7].strip cust = row[8].nil? ? 0 : row[8] # TODO: REMOVE BUSINESS LOGIC EMBEDDED IN CODE if comp == 'Security' and keyw.include?('Unconfirmed') puts "NB: This report has a hardcoded exclusion of 'Security' component bugs with the 'Unconfirmed' keyword." next end # Package up bug data binfo = { :snapdate => snapdate, :test_blocker => keyw.include?('TestBlocker'), :ops_blocker => keyw.include?('OpsBlocker'), :online_blocker => keyw.include?('OnlineStarter'), :owner => owns, :summary => summ, :status => stat, :component => comp, :pm_score => pmsc, :cust_cases => (cust == 1), :tgt_release => tgtr, } tgt_release = @config.release_by_target(tgtr) all_release = @config.release('All') # If this component isn't mapped to a team, stub out a fake team. tname = comp_map.has_key?(comp) ? comp_map[comp] : "(?) #{comp}" unless @org_data.has_key?(tname) @config.add_ad_hoc_team({ 'name' => tname, 'components' => [comp] }) @org_data[tname] = Shiftzilla::TeamData.new(tname) end team_rdata = tgt_release.nil? ? nil : @org_data[tname].get_release_data(tgt_release) team_adata = @org_data[tname].get_release_data(all_release) over_rdata = tgt_release.nil? ? nil : @org_data['_overall'].get_release_data(tgt_release) over_adata = @org_data['_overall'].get_release_data(all_release) # Do some bean counting [over_rdata,team_rdata,over_adata,team_adata].each do |group| next if group.nil? snapdata = group.get_snapdata(snapshot) if group.first_snap.nil? group.first_snap = snapshot group.first_snapdate = snapdate end group.latest_snap = snapshot group.latest_snapdate = snapdate bug = group.add_or_update_bug(bzid,binfo) # Add info to the snapshot snapdata.bug_ids << bzid if bug.test_blocker or bug.ops_blocker or bug.online_blocker snapdata.tb_ids << bzid end if bug.cust_cases snapdata.cc_ids << bzid end end end # Determine new and closed bug counts by comparing the current # snapshot to the previous snapshot @org_data.each do |tname,tdata| @releases.each do |release| next unless tdata.has_release_data?(release) rdata = tdata.get_release_data(release) next unless rdata.has_snapdata?(snapshot) if rdata.prev_snap.nil? rdata.prev_snap = snapshot next end currdata = rdata.get_snapdata(snapshot) prevdata = rdata.get_snapdata(rdata.prev_snap) prev_bzids = prevdata.bug_ids curr_bzids = currdata.bug_ids prev_tbids = prevdata.tb_ids curr_tbids = currdata.tb_ids prev_ccids = prevdata.cc_ids curr_ccids = currdata.cc_ids currdata.closed_bugs = prev_bzids.select{ |bzid| not curr_bzids.include?(bzid) }.length currdata.new_bugs = curr_bzids.select{ |bzid| not prev_bzids.include?(bzid) }.length currdata.closed_tb = prev_tbids.select{ |tbid| not curr_tbids.include?(tbid) }.length currdata.new_tb = curr_tbids.select{ |tbid| not prev_tbids.include?(tbid) }.length currdata.closed_cc = prev_ccids.select{ |ccid| not curr_ccids.include?(ccid) }.length currdata.new_cc = curr_ccids.select{ |ccid| not prev_ccids.include?(ccid) }.length rdata.prev_snap = snapshot end end end @all_teams = @teams.map{ |t| t.name }.concat(@org_data.keys).uniq @ordered_teams = ['_overall'].concat(@all_teams.select{ |t| t != '_overall'}.sort) end |
#publish_reports(ssh) ⇒ Object
283 284 285 286 |
# File 'lib/shiftzilla/org_data.rb', line 283 def publish_reports(ssh) system("ssh #{ssh[:host]} 'rm -rf #{ssh[:path]}/*'") system("rsync -avPq #{@tmp_dir}/* #{ssh[:host]}:#{ssh[:path]}/") end |
#show_local_reports ⇒ Object
278 279 280 281 |
# File 'lib/shiftzilla/org_data.rb', line 278 def show_local_reports puts "Local files available at #{@tmp_dir}" system("open file://#{@tmp_dir}/index.html") end |