Sha256: e907bf64a09bf5c43a03d2310ebae168f0d4a2aafe6f9fcc8b1ad6a74dc58f49

Contents?: true

Size: 933 Bytes

Versions: 76

Compression:

Stored size: 933 Bytes

Contents

module ForemanOpenscap::HostReportDashboard
  class Data
    attr_reader :report, :latest_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

    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

76 entries across 76 versions & 1 rubygems

Version Path
foreman_openscap-10.1.0 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-10.0.3 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-10.0.2 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-10.0.1 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-10.0.0 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-9.0.4 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-9.0.3 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-9.0.2 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-9.0.1 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-9.0.0 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-8.0.0 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-7.1.1 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-7.1.0 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-7.0.0 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-6.0.0 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-5.2.3 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-5.2.2 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-5.1.1 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-5.2.1 app/services/foreman_openscap/host_report_dashboard/data.rb
foreman_openscap-5.2.0 app/services/foreman_openscap/host_report_dashboard/data.rb