Sha256: 2783127ea678cd4b5cda1ddc9e8c1e65f9e9f59e7e651f24902c0b2d3f6edadd

Contents?: true

Size: 906 Bytes

Versions: 3

Compression:

Stored size: 906 Bytes

Contents

module ForemanOpenscap::ReportDashboard
  class Data
    attr_reader :report

    def initialize(filter = "")
      @filter = filter
      @report = {}
      fetch_data
    end

    private
    attr_writer :report
    attr_accessor :filter

    def fetch_data
      report.update(
        {
          :passed  => passed_breakdowns,
          :failed  => failed_breakdowns,
          :othered => othered_breakdowns
        }
      )
    end

    def passed_breakdowns
      Log.where(:result => 'pass').joins("INNER JOIN reports ON reports.id = report_id").count(:id).to_f
    end

    def failed_breakdowns
      Log.where(:result => 'fail').joins("INNER JOIN reports ON reports.id = report_id").count(:id).to_f
    end

    def othered_breakdowns
      Log.where(:result => ForemanOpenscap::ArfReport::RESULT[2..-1]).joins("INNER JOIN reports ON reports.id = report_id").count(:id).to_f
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman_openscap-0.5.3 app/services/foreman_openscap/report_dashboard/data.rb
foreman_openscap-0.5.2 app/services/foreman_openscap/report_dashboard/data.rb
foreman_openscap-0.5.1 app/services/foreman_openscap/report_dashboard/data.rb