Skip to content

Commit

Permalink
Delete missing static recurring tasks before loading them again
Browse files Browse the repository at this point in the history
Closes #382 and #420.
  • Loading branch information
rosa committed Nov 29, 2024
1 parent c521c6d commit ebba619
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/solid_queue/scheduler/recurring_schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def task_keys

private
def persist_tasks
SolidQueue::RecurringTask.static.where.not(key: task_keys).delete_all
SolidQueue::RecurringTask.create_or_update_all configured_tasks
end

Expand Down
4 changes: 2 additions & 2 deletions test/integration/recurring_tasks_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ class RecurringTasksTest < ActiveSupport::TestCase
scheduler1 = SolidQueue::Scheduler.new(recurring_tasks: another_task).tap(&:start)
wait_for_registered_processes(6, timeout: 1.second)

assert_recurring_tasks configured_task.merge(another_task)
assert_recurring_tasks another_task

updated_task = { example_task: { class: "AddToBufferJob", schedule: "every minute" } }
scheduler2 = SolidQueue::Scheduler.new(recurring_tasks: updated_task).tap(&:start)
wait_for_registered_processes(7, timeout: 1.second)

assert_recurring_tasks configured_task.merge(updated_task)
assert_recurring_tasks updated_task

terminate_process(@pid)
scheduler1.stop
Expand Down

0 comments on commit ebba619

Please sign in to comment.