Module: Shiftzilla::Engine
- Defined in:
- lib/shiftzilla/engine.rb
Instance Method Summary collapse
- #build_reports(options) ⇒ Object
- #check_config ⇒ Object
- #load_records(options) ⇒ Object
- #purge_records ⇒ Object
- #triage_report ⇒ Object
Instance Method Details
#build_reports(options) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/shiftzilla/engine.rb', line 112 def build_reports() org_data = Shiftzilla::OrgData.new(shiftzilla_config) org_data.populate_releases org_data.build_series org_data.generate_reports([:groups]) 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
11 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 |
# File 'lib/shiftzilla/engine.rb', line 11 def check_config if Shiftzilla.const_defined?('ARCH_DIR') and not File.directory?(Shiftzilla::ARCH_DIR) puts "You don't have an archive directory at #{Shiftzilla::ARCH_DIR}. Creating it." Dir.mkdir(Shiftzilla::ARCH_DIR) end if Shiftzilla.const_defined?('CFG_FILE') and not File.exists?(Shiftzilla::CFG_FILE) choose do || .header = "\nYou don't have a shiftzilla config file at #{Shiftzilla::CFG_FILE}. Should I create one?" .prompt = 'Choice?' .choice(:yes) { say("Okay. Creating #{Shiftzilla::CFG_FILE}") FileUtils.cp(CFG_TMPL,Shiftzilla::CFG_FILE) } .choice(:no) { say('Okay. Exiting Shiftzilla.') exit } end end if Shiftzilla.const_defined?('DB_FPATH') and not File.exists?(Shiftzilla::DB_FPATH) choose do || .header = "\nYou don't have a shiftzilla database file at #{Shiftzilla::DB_FPATH}.\nI can create it for you, but it is very important for you to\nconfigure Shiftzilla by puttng the proper settings in\n#{Shiftzilla::CFG_FILE} first.\nDo you want me to proceed with creating the database?" .prompt = 'Choice?' .choice(:yes) { say("Okay. Creating #{Shiftzilla::DB_FPATH}") sql_tmpl = File.read(SQL_TMPL) dbh.execute_batch(sql_tmpl) dbh.close exit } .choice(:no) { say('Okay. Exiting Shiftzilla.') exit } end end end |
#load_records(options) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/shiftzilla/engine.rb', line 49 def load_records() sources.each do |s| proceed = true if s.has_records_for_today? and not [:purge] 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
63 64 65 66 67 68 |
# File 'lib/shiftzilla/engine.rb', line 63 def purge_records sources.each do |s| s.purge_records end puts "Purged #{sources.length} tables." end |
#triage_report ⇒ Object
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 |
# File 'lib/shiftzilla/engine.rb', line 70 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 |