Sha256: d0977f1c641807b0804e60873e57add75c5331abcf57c1e8957812468bda320a
Contents?: true
Size: 1.23 KB
Versions: 16
Compression:
Stored size: 1.23 KB
Contents
module ForemanOpenscap class PolicyMailer < ::ApplicationMailer def policy_summary(options = {}) set_url user = ::User.find(options[:user]) @time = options[:time] || 1.day.ago @policies = ::ForemanOpenscap::Policy.all.reject { |policy| policy.assets.map(&:host).compact.empty? } @compliant_hosts = @policies.map { |policy| Host.comply_with policy }.flatten @incompliant_hosts = @policies.map { |policy| Host.incomply_with policy }.flatten changed_hosts_of_policies(@policies) if user.nil? || user.mail.nil? logger.warn "User with valid email not supplied, mail report will not be sent" else set_locale_for(user) do subject = _("SCAP policies summary") mail(:to => user.mail, :subject => subject) end end end private def changed_hosts_of_policies(policies) hash = @policies.inject({}) do |result, policy| result[policy.id] = policy.hosts result end @changed_hosts = [] hash.each do |key, values| values.each do |host| @changed_hosts << host if host.scap_status_changed?(::ForemanOpenscap::Policy.find(key)) end end @changed_hosts.uniq end end end
Version data entries
16 entries across 16 versions & 1 rubygems