Sha256: c5f78956b50cb5ecda51920c8f557dd7f3dee145548d284f26aaeb4725e6917e
Contents?: true
Size: 972 Bytes
Versions: 33
Compression:
Stored size: 972 Bytes
Contents
class InsightsHit < ApplicationRecord include ::Authorizable belongs_to :host # since the facet is one-to-one association with a host, we can connect # through host_id column on both this model and facet. belongs_to :insights_facet, foreign_key: 'host_id', primary_key: 'host_id', counter_cache: :hits_count has_one :rule, class_name: 'InsightsRule', foreign_key: 'rule_id', primary_key: 'rule_id' scope :with_playbook, -> { joins(:rule) } scoped_search on: :title, complete_value: true scoped_search on: :total_risk, complete_value: true scoped_search on: :rule_id, complete_value: true, only_explicit: true scoped_search relation: :host, on: :name, rename: :hostname, complete_value: true scoped_search on: :rule_id, rename: :with_playbook, only_explicit: true, complete_value: false, ext_method: :find_with_playbook def self.find_with_playbook(key, operator, value) { joins: :rule } end def has_playbook? !rule.nil? end end
Version data entries
33 entries across 33 versions & 1 rubygems