Class: InsightsCloud::Async::InsightsGenerateNotifications
- Inherits:
-
Actions::EntryAction
- Object
- Actions::EntryAction
- InsightsCloud::Async::InsightsGenerateNotifications
- Defined in:
- lib/insights_cloud/async/insights_generate_notifications.rb
Class Method Summary collapse
-
.blueprint ⇒ Object
cache blueprint on class level, so it won’t be reloaded on subsequent calls.
Instance Method Summary collapse
Class Method Details
.blueprint ⇒ Object
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_notifications ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/insights_cloud/async/insights_generate_notifications.rb', line 15 def add_satellite_notifications host = foreman_host # Skip if no Foreman host record exists unless host logger.debug("Skipping Insights notifications: no Foreman host record found") blueprint&.notifications&.destroy_all return end hits_count = InsightsHit.where(host_id: host.id).count # Remove stale notifications blueprint.notifications.destroy_all if hits_count > 0 add_notification(hits_count) end end |
#run ⇒ Object
11 12 13 |
# File 'lib/insights_cloud/async/insights_generate_notifications.rb', line 11 def run add_satellite_notifications end |