Sha256: 6d5edacf9801e7ceb267eed8a5e673bea93440c40dd74d40fc987b152fb90ebb

Contents?: true

Size: 566 Bytes

Versions: 5

Compression:

Stored size: 566 Bytes

Contents

class CalcExistingReports < ActiveRecord::Migration
  def self.up
    if (rc = Report.count) > 0
      Report.reset_column_information
      say_with_time "updating Reports records - this may take a long time.. we have #{rc} reports to process hold on" do
        Report.find_each do |r|
          begin
            r.update_single_attribute(:status, Report.calc_status(Report.metrics_to_hash(r.log)))
          rescue Exception => e
            say "#{r.id}: #{e} - ignoring this report"
          end
        end
      end
    end
  end

  def self.down
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_discovery-1.0.0 test/foreman_app/db/migrate/20091214045923_calc_existing_reports.rb
foreman_discovery-1.0.0.rc4 test/foreman_app/db/migrate/20091214045923_calc_existing_reports.rb
foreman_discovery-1.0.0.rc3 test/foreman_app/db/migrate/20091214045923_calc_existing_reports.rb
foreman_discovery-1.0.0.rc2 test/foreman_app/db/migrate/20091214045923_calc_existing_reports.rb
foreman_discovery-1.0.0.rc1 test/foreman_app/db/migrate/20091214045923_calc_existing_reports.rb