Sha256: 783cc8843eff45d28b32d8360d24fa5b6b2048a7e3154d77661b6ece6e76a733

Contents?: true

Size: 1 KB

Versions: 73

Compression:

Stored size: 1 KB

Contents

class ReplaceArfReportBreakdownView < ActiveRecord::Migration[4.2]
  def self.up
    execute 'DROP VIEW IF EXISTS scaptimony_arf_report_breakdowns'
    execute <<-SQL.strip_heredoc
      CREATE VIEW scaptimony_arf_report_breakdowns AS
        SELECT
          arf.id as arf_report_id,
          COUNT(CASE WHEN result.name IN ('pass','fixed') THEN 1 ELSE null END) as passed,
          COUNT(CASE result.name WHEN 'fail' THEN 1 ELSE null END) as failed,
          COUNT(CASE WHEN result.name NOT IN ('pass', 'fixed', 'fail', 'notselected', 'notapplicable') THEN 1 ELSE null END) as othered
        FROM
          scaptimony_arf_reports arf
        LEFT OUTER JOIN
          scaptimony_xccdf_rule_results rule
          ON arf.id = rule.arf_report_id
        LEFT OUTER JOIN scaptimony_xccdf_results result
          ON rule.xccdf_result_id = result.id
        GROUP BY arf.id;
    SQL
  end

  def self.down
    execute 'DROP VIEW scaptimony_arf_report_breakdowns' if table_exists? 'scaptimony_arf_report_breakdowns'
  end
end

Version data entries

73 entries across 73 versions & 1 rubygems

Version Path
foreman_openscap-10.1.0 db/migrate/20141121164042_replace_arf_report_breakdown_view.rb
foreman_openscap-10.0.3 db/migrate/20141121164042_replace_arf_report_breakdown_view.rb
foreman_openscap-10.0.2 db/migrate/20141121164042_replace_arf_report_breakdown_view.rb
foreman_openscap-10.0.1 db/migrate/20141121164042_replace_arf_report_breakdown_view.rb
foreman_openscap-10.0.0 db/migrate/20141121164042_replace_arf_report_breakdown_view.rb
foreman_openscap-9.0.4 db/migrate/20141121164042_replace_arf_report_breakdown_view.rb
foreman_openscap-9.0.3 db/migrate/20141121164042_replace_arf_report_breakdown_view.rb
foreman_openscap-9.0.2 db/migrate/20141121164042_replace_arf_report_breakdown_view.rb
foreman_openscap-9.0.1 db/migrate/20141121164042_replace_arf_report_breakdown_view.rb
foreman_openscap-9.0.0 db/migrate/20141121164042_replace_arf_report_breakdown_view.rb
foreman_openscap-8.0.0 db/migrate/20141121164042_replace_arf_report_breakdown_view.rb
foreman_openscap-7.1.1 db/migrate/20141121164042_replace_arf_report_breakdown_view.rb
foreman_openscap-7.1.0 db/migrate/20141121164042_replace_arf_report_breakdown_view.rb
foreman_openscap-7.0.0 db/migrate/20141121164042_replace_arf_report_breakdown_view.rb
foreman_openscap-6.0.0 db/migrate/20141121164042_replace_arf_report_breakdown_view.rb
foreman_openscap-5.2.3 db/migrate/20141121164042_replace_arf_report_breakdown_view.rb
foreman_openscap-5.2.2 db/migrate/20141121164042_replace_arf_report_breakdown_view.rb
foreman_openscap-5.1.1 db/migrate/20141121164042_replace_arf_report_breakdown_view.rb
foreman_openscap-5.2.1 db/migrate/20141121164042_replace_arf_report_breakdown_view.rb
foreman_openscap-5.2.0 db/migrate/20141121164042_replace_arf_report_breakdown_view.rb