Skip to content

Commit

Permalink
Merge pull request #289 from alphagov/fix-sidekiq-array-problem
Browse files Browse the repository at this point in the history
Remove brackets, array handling
  • Loading branch information
KludgeKML committed Oct 19, 2023
2 parents 1706d3c + 7b0839f commit 2816f73
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/sidekiq_scheduler_backoff_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ def record_failure

def current_interval
schedule = Sidekiq.get_schedule[name]
Integer(schedule["every"].first.chop)
Integer(schedule["every"].chop)
end

def restart_schedule(target_interval)
schedule = Sidekiq.get_schedule[name]
Sidekiq.set_schedule(name, schedule.merge("every" => ["#{target_interval}s"]))
Sidekiq.set_schedule(name, schedule.merge("every" => "#{target_interval}s"))
end
end
18 changes: 9 additions & 9 deletions spec/lib/sidekiq_scheduler_backoff_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

it "sets the scheduler to maximum speed and reloads the schedule" do
subject.record_failure
expect(scheduled_interval).to eq(["#{min_interval}s"])
expect(scheduled_interval).to eq("#{min_interval}s")
end
end

Expand All @@ -25,7 +25,7 @@

it "halves the scheduler speed and reloads the schedule" do
subject.record_failure
expect(scheduled_interval).to eq(["#{max_interval}s"])
expect(scheduled_interval).to eq("#{max_interval}s")
end
end

Expand All @@ -36,7 +36,7 @@

it "does nothing" do
subject.record_failure
expect(scheduled_interval).to eq(["#{max_interval}s"])
expect(scheduled_interval).to eq("#{max_interval}s")
end
end

Expand All @@ -47,7 +47,7 @@

it "sets the scheduler to minimum speed and reloads the schedule" do
subject.record_failure
expect(scheduled_interval).to eq(["#{max_interval}s"])
expect(scheduled_interval).to eq("#{max_interval}s")
end
end
end
Expand All @@ -60,7 +60,7 @@

it "sets the scheduler to maximum speed and reloads the schedule" do
subject.record_success
expect(scheduled_interval).to eq(["#{min_interval}s"])
expect(scheduled_interval).to eq("#{min_interval}s")
end
end

Expand All @@ -71,7 +71,7 @@

it "does nothing" do
subject.record_success
expect(scheduled_interval).to eq(["#{min_interval}s"])
expect(scheduled_interval).to eq("#{min_interval}s")
end
end

Expand All @@ -82,7 +82,7 @@

it "decremenincrements the scheduler speed by 1 second and reloads the schedule" do
subject.record_success
expect(scheduled_interval).to eq(["#{(min_interval * 4) - 1}s"])
expect(scheduled_interval).to eq("#{(min_interval * 4) - 1}s")
end
end

Expand All @@ -93,14 +93,14 @@

it "sets the scheduler to minimum speed and reloads the schedule" do
subject.record_success
expect(scheduled_interval).to eq(["#{max_interval}s"])
expect(scheduled_interval).to eq("#{max_interval}s")
end
end
end
end

def set_scheduled_interval(interval)
Sidekiq.set_schedule(name.to_s, { "every" => ["#{interval}s"], "class" => "PostcodesCollectionWorker" })
Sidekiq.set_schedule(name.to_s, { "every" => "#{interval}s", "class" => "PostcodesCollectionWorker" })
end

def scheduled_interval
Expand Down

0 comments on commit 2816f73

Please sign in to comment.