[deploy] Refactor:Move Sitemap Refresh Rake Task to Sidekiq (#9975)
This commit is contained in:
parent
99e4029078
commit
a4373346dd
3 changed files with 30 additions and 0 deletions
10
app/workers/sitemap_refresh_worker.rb
Normal file
10
app/workers/sitemap_refresh_worker.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
class SitemapRefreshWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options queue: :low_priority, retry: 10
|
||||
|
||||
def perform
|
||||
Rails.application.load_tasks
|
||||
Rake::Task["sitemap:refresh"].invoke
|
||||
end
|
||||
end
|
||||
|
|
@ -74,6 +74,9 @@ expire_old_listings:
|
|||
send_welcome_notifications:
|
||||
cron: "0 16 * * *" # daily at 4 pm UTC
|
||||
class: "Broadcasts::SendWelcomeNotificationsWorker"
|
||||
sitemap_refresh:
|
||||
cron: "30 * * * *" # every hour, 30 min after the hour
|
||||
class: "SitemapRefreshWorker"
|
||||
hourly_feed_cache_bust:
|
||||
cron: "0 * * * *" # hourly on the hour
|
||||
class: "BustCachePathWorker"
|
||||
|
|
|
|||
17
spec/workers/sitemap_refresh_worker_spec.rb
Normal file
17
spec/workers/sitemap_refresh_worker_spec.rb
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe SitemapRefreshWorker, type: :woker do
|
||||
include_examples "#enqueues_on_correct_queue", "low_priority"
|
||||
|
||||
describe "#perform" do
|
||||
let(:worker) { subject }
|
||||
|
||||
it "runs sitemap refresh rake task" do
|
||||
allow(Rails.application).to receive(:load_tasks)
|
||||
mock_task = instance_double(Rake::Task, invoke: true)
|
||||
allow(Rake::Task).to receive(:[]).and_return(mock_task)
|
||||
worker.perform
|
||||
expect(Rake::Task).to have_received(:[]).with("sitemap:refresh")
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue