Skip to content
Permalink
Browse files

Setup Slack notifications for completed jobs.

- Notifications for:
  - Once a seed job is done
  - Once a download job is done
  - Once analysis is complete
- Fix a bad url in sitemap config
- Update Rubocop config
- Add Slack Notification gem: https://github.com/stevenosloan/slack-notifier
  • Loading branch information...
ruebot committed Feb 13, 2019
1 parent dedc9c8 commit a45e629ec6ea5106b9e4e23db2f3c529f63d722a
@@ -50,6 +50,7 @@ Metrics/LineLength:
- app/jobs/graphpass_job.rb
- app/jobs/spark_job.rb
- app/jobs/textfilter_job.rb
- app/jobs/wasapi_download_job.rb
- app/jobs/wasapi_seed_job.rb
- app/mailers/user_mailer.rb
- test/helpers/collections_helper_test.rb
@@ -84,5 +84,6 @@ gem 'rubocop', '~> 0.61.1'
gem 'rubocop-rspec', '~> 1.30.1'
gem 'rubyzip', '>= 1.2.2' # https://nvd.nist.gov/vuln/detail/CVE-2018-1000544
gem 'sitemap_generator'
gem 'slack-notifier'
gem 'sys-filesystem'
gem 'time_difference'
@@ -257,6 +257,7 @@ GEM
simplecov-html (0.10.2)
sitemap_generator (6.0.2)
builder (~> 3.0)
slack-notifier (2.3.2)
spring (2.0.2)
activesupport (>= 4.2)
spring-watcher-listen (2.0.1)
@@ -338,6 +339,7 @@ DEPENDENCIES
sass-rails (~> 5.0)
simplecov
sitemap_generator
slack-notifier
spring
spring-watcher-listen (~> 2.0.0)
sqlite3
@@ -1,4 +1,5 @@
# frozen_string_literal: true

# Methods for Jobs.
class ApplicationJob < ActiveJob::Base
end
@@ -14,6 +14,10 @@ class TextfilterJob < ApplicationJob
update_dashboard = Dashboard.find_by(job_id: job_id)
update_dashboard.end_time = DateTime.now.utc
update_dashboard.save
user = User.find(job.arguments.first)
collection = Collection.find(job.arguments.second)
message = "Analysis of \"#{collection.title}\" for #{user.auk_name} has completed."
SLACK.ping message
end

def perform(user_id, collection_id)
@@ -14,6 +14,8 @@ class WasapiDownloadJob < ApplicationJob
update_dashboard = Dashboard.find_by(job_id: job_id)
update_dashboard.end_time = DateTime.now.utc
update_dashboard.save
message = "Download of \"#{job.arguments.second.title}\" for #{job.arguments.first.auk_name} has finished."
SLACK.ping message
end

def perform(user_id, collection_id)
@@ -15,6 +15,8 @@ class WasapiSeedJob < ApplicationJob
update_dashboard = Dashboard.find_by(job_id: job_id)
update_dashboard.end_time = DateTime.now.utc
update_dashboard.save
message = "Seed job for #{job.arguments.first.auk_name} at #{job.arguments.first.institution} has finished."
SLACK.ping message
end

def perform(user)
@@ -33,6 +33,7 @@ DASHBOARD_USER: "test"
DASHBOARD_PASS: "test"
BASE_HOSTNAME: "cloud.archivesunleashed.org" #if in development mode: localhost:3000
BASE_HOST_URL: "https://cloud.archivesunleashed.org" #if in development mode: http://localhost:3000
SLACK_WEBHOOK_URL: "https://hooks.slack.com/services/SOME/IDENTIFER" #https://slack.com/apps/A0F7XDUAZ-incoming-webhooks

production:
SECRET_KEY_BASE: "some secret key base"
@@ -0,0 +1,6 @@
# frozen_string_literal: true

SLACK = Slack::Notifier.new ENV['SLACK_WEBHOOK_URL'],
channel: '#auk-jobs',
username: 'auk-bot',
icon_emoji: ':auk:'
@@ -8,7 +8,7 @@
add '/derivatives', changefreq: 'monthly', priority: 0.9
add '/derivatives/gephi', changefreq: 'monthly', priority: 0.9
add '/derivatives/text-antconc', changefreq: 'monthly', priority: 0.9
add 'derivatives/text-filtering', changefreq: 'monthly', priority: 0.9
add '/derivatives/text-filtering', changefreq: 'monthly', priority: 0.9
add '/derivatives/text-sentiment', changefreq: 'monthly', priority: 0.9
add '/derivatives/domains', changefreq: 'monthly', priority: 0.9
end

0 comments on commit a45e629

Please sign in to comment.
You can’t perform that action at this time.