Skip to content

Commit

Permalink
notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
kjgarza committed Nov 20, 2018
1 parent d034dbc commit b5b4b4b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion app/jobs/usage_update_parse_job.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
class UsageUpdateParseJob < ActiveJob::Base
queue_as :levriero

ICON_URL = "https://raw.githubusercontent.com/datacite/toccatore/master/lib/toccatore/images/toccatore.png"


def perform(item, options={})
logger = Logger.new(STDOUT)
response = UsageUpdate.get_data(item, options)
Expand Down Expand Up @@ -40,6 +43,17 @@ def send_message data, item, options={}
end

logger.info text
send_notification_to_slack(text, options) if options[:slack_webhook_url].present?

if options[:slack_webhook_url].present?
attachment = {
title: options[:title] || "Report",
text: text,
color: options[:level] || "good"
}
notifier = Slack::Notifier.new options[:slack_webhook_url],
username: "Event Data Agent",
icon_url: ICON_URL
notifier.post attachments: [attachment]
end
end
end

0 comments on commit b5b4b4b

Please sign in to comment.