Sha256: 1cfe729f2690467e298b3c7f663fa5a6cc2c45747321632aac999d785c39111f

Contents?: true

Size: 646 Bytes

Versions: 24

Compression:

Stored size: 646 Bytes

Contents

class FixIncorrectReportMetrics < ActiveRecord::Migration
  def up
    Report.all.each do |report|
      next unless report.metrics && report.metrics['time']
      metrics = report.metrics.dup

      report.metrics['time'].each do |resource, time|
        metrics['time'][resource] = if time.is_a? String
                                      Float(time.delete(' ms')) rescue nil
                                    else
                                      time
                                    end
      end

      report.update_attributes(:metrics => metrics) if metrics != report.metrics
    end
  end

  def down
    # Nothing
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
foreman_salt-2.1.0 db/migrate/20150220122707_fix_incorrect_report_metrics.rb
foreman_salt-2.0.2 db/migrate/20150220122707_fix_incorrect_report_metrics.rb
foreman_salt-2.0.1 db/migrate/20150220122707_fix_incorrect_report_metrics.rb
foreman_salt-2.0.0 db/migrate/20150220122707_fix_incorrect_report_metrics.rb