Skip to content

Commit

Permalink
Remove some now unnecessary checks against locked_by_id existence (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Earlopain authored Jul 15, 2024
1 parent 4cc65c5 commit 74c2600
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions app/models/good_job/base_execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -481,11 +481,7 @@ def perform(lock_id:)
end
end

job_attributes = if self.class.columns_hash.key?("locked_by_id")
{ locked_by_id: nil, locked_at: nil }
else
{}
end
job_attributes = { locked_by_id: nil, locked_at: nil }

job_error = result.handled_error || result.unhandled_error
if job_error
Expand Down
4 changes: 2 additions & 2 deletions app/models/good_job/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Process < BaseRecord
self.table_name = 'good_job_processes'

has_many :locked_jobs, class_name: "GoodJob::Job", foreign_key: :locked_by_id, inverse_of: :locked_by_process, dependent: nil
after_destroy { locked_jobs.update_all(locked_by_id: nil) if GoodJob::Job.columns_hash.key?("locked_by_id") } # rubocop:disable Rails/SkipsModelValidations
after_destroy { locked_jobs.update_all(locked_by_id: nil) } # rubocop:disable Rails/SkipsModelValidations

# Processes that are active and locked.
# @!method active
Expand All @@ -51,7 +51,7 @@ class Process < BaseRecord
# Deletes all inactive process records.
def self.cleanup
inactive.find_each do |process|
GoodJob::Job.where(locked_by_id: process.id).update_all(locked_by_id: nil, locked_at: nil) if GoodJob::Job.columns_hash.key?("locked_by_id") # rubocop:disable Rails/SkipsModelValidations
GoodJob::Job.where(locked_by_id: process.id).update_all(locked_by_id: nil, locked_at: nil) # rubocop:disable Rails/SkipsModelValidations
process.delete
end
end
Expand Down

0 comments on commit 74c2600

Please sign in to comment.