Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a few method redefinition warnings #1459

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/models/concerns/good_job/error_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ module ErrorEvents
discarded: 5,
}
if Gem::Version.new(Rails.version) >= Gem::Version.new('7.1.0.a')
enum :error_event, error_event_enum, validate: { allow_nil: true }
enum :error_event, error_event_enum, validate: { allow_nil: true }, scopes: false
else
enum error_event: error_event_enum
enum error_event: error_event_enum, _scopes: false
end
end
end
Expand Down
22 changes: 2 additions & 20 deletions app/models/good_job/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ class Job < BaseRecord
# Execution errored, will run in the future
scope :retried, -> { where(finished_at: nil).where(coalesce_scheduled_at_created_at.gt(bind_value('coalesce', Time.current, ActiveRecord::Type::DateTime))).where(params_execution_count.gt(1)) }
# Immediate/Scheduled time to run has passed, waiting for an available thread run
scope :queued, -> { where(performed_at: nil, finished_at: nil).where(coalesce_scheduled_at_created_at.lteq(bind_value('coalesce', Time.current, ActiveRecord::Type::DateTime))).joins_advisory_locks.where(pg_locks: { locktype: nil }) }
scope :queued, -> { where(performed_at: nil, finished_at: nil).where(coalesce_scheduled_at_created_at.lteq(bind_value('coalesce', Time.current, ActiveRecord::Type::DateTime))) }
# Advisory locked and executing
scope :running, -> { where.not(performed_at: nil).where(finished_at: nil).joins_advisory_locks.where.not(pg_locks: { locktype: nil }) }
scope :running, -> { where.not(performed_at: nil).where(finished_at: nil) }
# Finished executing (succeeded or discarded)
scope :finished, -> { where.not(finished_at: nil) }
# Completed executing successfully
Expand Down Expand Up @@ -140,24 +140,6 @@ class Job < BaseRecord
# @return [ActiveRecord::Relation]
scope :schedule_ordered, -> { order(coalesce_scheduled_at_created_at.asc) }

# Get completed jobs before the given timestamp. If no timestamp is
# provided, get *all* completed jobs. By default, GoodJob
# destroys jobs after they're completed, meaning this returns no jobs.
# However, if you have changed {GoodJob.preserve_job_records}, this may
# find completed Jobs.
# @!method finished(timestamp = nil)
# @!scope class
# @param timestamp (Float)
# Get jobs that finished before this time (in epoch time).
# @return [ActiveRecord::Relation]
scope :finished, ->(timestamp = nil) { timestamp ? where(arel_table['finished_at'].lteq(bind_value('finished_at', timestamp, ActiveRecord::Type::DateTime))) : where.not(finished_at: nil) }

# Get Jobs that started but not finished yet.
# @!method running
# @!scope class
# @return [ActiveRecord::Relation]
scope :running, -> { where.not(performed_at: nil).where(finished_at: nil) }

# Get Jobs on queues that match the given queue string.
# @!method queue_string(string)
# @!scope class
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 @@ -20,9 +20,9 @@ class Process < BaseRecord
advisory: 0,
}
if Gem::Version.new(Rails.version) >= Gem::Version.new('7.1.0.a')
enum :lock_type, lock_type_enum, validate: { allow_nil: true }
enum :lock_type, lock_type_enum, validate: { allow_nil: true }, scopes: false
else
enum lock_type: lock_type_enum
enum lock_type: lock_type_enum, _scopes: false
end

has_many :locked_jobs, class_name: "GoodJob::Job", foreign_key: :locked_by_id, inverse_of: :locked_by_process, dependent: nil
Expand Down