Module: Shiftzilla::Engine
- Defined in:
- lib/shiftzilla/engine.rb
Instance Method Summary collapse
- #build_reports(options) ⇒ Object
- #check_config ⇒ Object
- #load_records ⇒ Object
- #purge_records ⇒ Object
- #triage_report ⇒ Object
Instance Method Details
#build_reports(options) ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/shiftzilla/engine.rb', line 129 def build_reports() org_data = Shiftzilla::OrgData.new(shiftzilla_config) org_data.populate_releases org_data.build_series org_data.generate_reports if [:local_preview] org_data.show_local_reports else org_data.publish_reports(ssh) system("rm -rf #{org_data.tmp_dir}") unless [:quiet] system("open #{ssh[:url]}") end end end |
#check_config ⇒ Object
12 13 14 15 16 17 18 19 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 |
# File 'lib/shiftzilla/engine.rb', line 12 def check_config if not File.directory?(SZA_DIR) choose do || .header = 'You don\'t have a Shiftzilla config directory at $HOME/.shiftzilla. Should I create one?' .prompt = 'Choice?' .choice(:yes) { say('Okay. Creating config directory.') Dir.mkdir(SZA_DIR) Dir.mkdir(ARCH_DIR) } .choice(:no) { say('Okay. Exiting Shiftzilla.') exit } end end if not File.directory?(ARCH_DIR) puts 'You don\'t have an archive directory at $HOME/.shiftzilla/archive. Creating it.' Dir.mkdir(ARCH_DIR) end if not File.exists?(CFG_FILE) choose do || .header = "\nYou don't have a shiftzilla_cfg.yml file in $HOME/.shiftzilla. Should I create one?" .prompt = 'Choice?' .choice(:yes) { say('Okay. Creating shiftzilla_cfg.yml') FileUtils.cp(CFG_TMPL,CFG_FILE) } .choice(:no) { say('Okay. Exiting Shiftzilla.') exit } end end if not File.exists?(DB_FPATH) choose do || .header = "\nYou don't have a shiftzilla.sqlite file in $HOME/.shiftzilla.\nI can create it for you, but it is very important for you to\nconfigure Shiftzilla by puttng the proper settings in\n$HOME/.shiftzilla/shiftzilla_cfg.yml first. Do you want me to proceed with creating the database?" .prompt = 'Choice?' .choice(:yes) { say('Okay. Creating shiftzilla.sqlite') sql_tmpl = File.read(SQL_TMPL) tgt_rel_clause = release_clause(releases) sql_tmpl.gsub! '$RELEASE_CLAUSE', tgt_rel_clause dbh.execute_batch(sql_tmpl) dbh.close exit } .choice(:no) { say('Okay. Exiting Shiftzilla.') exit } end end end |
#load_records ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/shiftzilla/engine.rb', line 67 def load_records sources.each do |s| if s.has_records_for_today? puts "Skipping query for #{s.id}; it already has records for today." else backup_db puts "Querying bugzilla for #{s.id}" added_count = s.load_records puts "Added #{added_count} records to #{s.table}" end end end |
#purge_records ⇒ Object
80 81 82 83 84 85 |
# File 'lib/shiftzilla/engine.rb', line 80 def purge_records sources.each do |s| s.purge_records end puts "Purged #{sources.length} tables." end |
#triage_report ⇒ Object
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 |
# File 'lib/shiftzilla/engine.rb', line 87 def triage_report org_data = Shiftzilla::OrgData.new(shiftzilla_config) org_data.populate_releases teams = org_data.get_ordered_teams no_tgt_rel = shiftzilla_config.releases[0] teams.each do |tname| next if tname == '_overall' rdata = org_data.get_release_data(tname,no_tgt_rel) next if rdata.nil? or rdata.snaps.empty? recipients = {} team = shiftzilla_config.team(tname) unless team.nil? or team.ad_hoc? recipients[team.lead] = 1 recipients[team.group.lead] = 1 end bzids = rdata.snaps.has_key?(latest_snapshot) ? rdata.snaps[latest_snapshot].bug_ids : [] next if bzids.length == 0 bugs = rdata.bugs table = Terminal::Table.new do |t| t << ['URL','Age','Component','Owner','Summary'] t << :separator bzids.sort_by{ |b| [bugs[b].first_seen,bugs[b].component] }.each do |bzid| bug = bugs[bzid] if team.nil? recipients[bug.owner] = 1 end t << [ bug_url(bzid), bug.age, bug.component, bug.owner, bug.summary ] end end puts "#{tname}#{team.nil? ? ' Component' : ' Team'} - #{bzids.length} bugs with no Target Release" puts "To: #{recipients.keys.sort.join(',')}" puts "#{table}\n\n" end end |