Skip to content

Commit

Permalink
Rename CsvExportWorker -> CsvExportJob
Browse files Browse the repository at this point in the history
Sidekiq::Worker has been deprecated in Sidekiq 7.

This replaces all instances of Sidekiq::Worker with Sidekiq::Job and
renames/moves workers to app/sidekiq/MyJob.rb.
  • Loading branch information
AgaDufrat committed Oct 18, 2024
1 parent a841df8 commit a690c1a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/controllers/content_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def export_csv
@recipient = current_user.email

start_time_string = Time.zone.now.to_s
CsvExportWorker.perform_async(search_params.stringify_keys, @recipient, start_time_string)
CsvExportJob.perform_async(search_params.stringify_keys, @recipient, start_time_string)
end

private
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require "prometheus/client"
require "prometheus/client/push"

class CsvExportWorker
class CsvExportJob
include FileStorage
include Sidekiq::Worker
include Sidekiq::Job

sidekiq_options retry: 0
sidekiq_options queue: "export_csv"
Expand Down Expand Up @@ -61,3 +61,5 @@ def push_metrics_to_pushgateway(elapsed_time_seconds)
).add(prometheus_registry)
end
end

CsvExportWorker = CsvExportJob ## TODO: Remove once queued jobs at the time of the upgrade are complete
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "govuk_sidekiq/testing"

RSpec.describe CsvExportWorker do
RSpec.describe CsvExportJob do
let(:search_params) do
{
date_range: "past-30-days",
Expand Down Expand Up @@ -68,7 +68,7 @@
let(:csv_export_histogram) { instance_spy(Prometheus::Client::Histogram) }

before do
Sidekiq::Worker.clear_all
Sidekiq::Job.clear_all

ENV["AWS_CSV_EXPORT_BUCKET_NAME"] = "test-bucket"
ENV["PROMETHEUS_PUSHGATEWAY_URL"] = "http://prometheus-pushgateway.local"
Expand Down

0 comments on commit a690c1a

Please sign in to comment.