[deploy] Refactor:Move remove_old_notifications Rake Task to Sidekiq (#9936)

* Refactor:Move remove_old_notifications Rake Task to Sidekiq

* fix typo
This commit is contained in:
Molly Struve 2020-08-24 07:48:46 -05:00 committed by GitHub
parent 17df627f0d
commit e07c707ede
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 3 deletions

View file

@ -0,0 +1,11 @@
module Notifications
class RemoveOldNotificationsWorker
include Sidekiq::Worker
sidekiq_options queue: :low_priority, retry: 10
def perform
Notification.fast_destroy_old_notifications
end
end
end

View file

@ -77,3 +77,6 @@ send_welcome_notifications:
send_email_digest:
cron: "30 11 * * 3,4,5,6" # 11:30 am UTC Wed, Thurs, Fri, Sat, Sun
class: "SendEmailDigestWorker"
remove_old_notifications:
cron: "0 5 * * *" # daily at 5 am UTC
class: "Notifications::RemoveOldNotificationsWorker"

View file

@ -1,3 +0,0 @@
task remove_old_notifications: :environment do
Notification.fast_destroy_old_notifications
end

View file

@ -0,0 +1,15 @@
require "rails_helper"
RSpec.describe Notifications::RemoveOldNotificationsWorker, type: :woker do
include_examples "#enqueues_on_correct_queue", "low_priority"
describe "#perform" do
let(:worker) { subject }
it "fast destroys notifications" do
allow(Notification).to receive(:fast_destroy_old_notifications)
worker.perform
expect(Notification).to have_received(:fast_destroy_old_notifications)
end
end
end