Class: PagerDuty::PollMaintenanceWindows
- Inherits:
-
Object
- Object
- PagerDuty::PollMaintenanceWindows
show all
- Includes:
- SentryLogging, Sidekiq::Job
- Defined in:
- app/sidekiq/pager_duty/poll_maintenance_windows.rb
Constant Summary
collapse
- MESSAGE_INDICATOR =
'USER_MESSAGE:'
Instance Method Summary
collapse
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
Instance Method Details
#parse_user_message(raw_description) ⇒ Object
13
14
15
|
# File 'app/sidekiq/pager_duty/poll_maintenance_windows.rb', line 13
def parse_user_message(raw_description)
raw_description.partition(MESSAGE_INDICATOR)[2].strip
end
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/sidekiq/pager_duty/poll_maintenance_windows.rb', line 17
def perform
client = PagerDuty::MaintenanceClient.new
pd_windows = client.get_all
pd_windows.each do |pd_win|
pd_win[:description] = parse_user_message(pd_win[:description])
window = MaintenanceWindow.find_or_initialize_by(pagerduty_id: pd_win[:pagerduty_id],
external_service: pd_win[:external_service])
window.update(pd_win)
end
open_ids = pd_windows.pluck(:pagerduty_id)
MaintenanceWindow.end_after(Time.zone.now).each do |api_win|
api_win.delete unless open_ids.include?(api_win.)
end
rescue Common::Exceptions::BackendServiceException, Common::Client::Errors::ClientError => e
log_exception_to_sentry(e)
end
|