Class: InsightsCloud::Async::InsightsGenerateNotifications

Inherits:
Actions::EntryAction
  • Object
show all
Defined in:
lib/insights_cloud/async/insights_generate_notifications.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.blueprintObject

cache blueprint on class level, so it won’t be reloaded on subsequent calls



7
8
9
# File 'lib/insights_cloud/async/insights_generate_notifications.rb', line 7

def self.blueprint
  @blueprint ||= NotificationBlueprint.find_by(name: 'insights_satellite_hits')
end

Instance Method Details

#add_satellite_notificationsObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/insights_cloud/async/insights_generate_notifications.rb', line 15

def add_satellite_notifications
  hits_count = InsightsHit.where(host_id: foreman_host.id).count

  # Remove stale notifications
  blueprint.notifications.destroy_all

  if hits_count > 0
    add_notification(hits_count)
  end
end

#runObject



11
12
13
# File 'lib/insights_cloud/async/insights_generate_notifications.rb', line 11

def run
  add_satellite_notifications
end