Sha256: e00686658f1ac7a14fef125b9b137895d91c552c66bb8d3f788df9104c11a1ff

Contents?: true

Size: 864 Bytes

Versions: 14

Compression:

Stored size: 864 Bytes

Contents

module ForemanOpenscap::HostReportDashboard
  class Data
    attr_reader :report

    def initialize(policy, host)
      @latest_report = ::ForemanOpenscap::ArfReport.latest_of_policy(policy)
        .where(:host_id => host.id)
        .order('created_at DESC').first
      @report = {}
      fetch_data
    end

    def has_data?
      latest_report.present?
    end

    private
    attr_writer :report
    attr_accessor :latest_report

    def fetch_data
      report.update(
        {
          :passed  => report_passed,
          :failed  => report_failed,
          :othered => report_othered
        }
      )
    end

    def report_passed
      has_data? ? @latest_report.passed : 0
    end

    def report_failed
      has_data? ? @latest_report.failed : 0
    end

    def report_othered
      has_data? ? @latest_report.othered : 0
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
foreman_openscap-0.7.1 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-0.6.7 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-0.7.0 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-0.6.6 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-0.6.5 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-0.6.4 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-0.6.3 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-0.6.2 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-0.6.1 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-0.6.0 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-0.5.4 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-0.5.3 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-0.5.2 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-0.5.1 app/services/foreman_openscap/host_report_dashboard/data.rb