Skip to content

Commit

Permalink
Don't be fancy with bind parameters just yet
Browse files Browse the repository at this point in the history
  • Loading branch information
bensheldon committed Mar 15, 2024
1 parent e02fc84 commit 0c3541a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/good_job/active_job_extensions/concurrency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def deserialize(job_data)

query = DiscreteExecution.joins(:job)
.where(GoodJob::Job.table_name => { concurrency_key: key })
.where(DiscreteExecution.arel_table[:created_at].gt(ActiveModel::Attribute.with_cast_value("created_at", throttle_period.ago, ActiveModel::Type.default_value)))
.where(DiscreteExecution.arel_table[:created_at].gt(throttle_period.ago))
allowed_active_job_ids = query.where(error: nil).or(query.where.not(error: "GoodJob::ActiveJobExtensions::Concurrency::ThrottleExceededError: GoodJob::ActiveJobExtensions::Concurrency::ThrottleExceededError"))
.order(created_at: :asc)
.limit(throttle_limit)
Expand Down Expand Up @@ -192,7 +192,7 @@ def good_job_enqueue_concurrency_check(job, on_abort:, on_enqueue:)
throttle_limit = throttle[0]
throttle_period = throttle[1]
enqueued_within_period = GoodJob::Job.where(concurrency_key: key)
.where(GoodJob::Job.arel_table[:created_at].gt(Arel::Nodes::BindParam.new(ActiveModel::Attribute.with_cast_value("created_at", throttle_period.ago, ActiveModel::Type.default_value))))
.where(GoodJob::Job.arel_table[:created_at].gt(throttle_period.ago))
.count

if (enqueued_within_period + 1) > throttle_limit
Expand Down

0 comments on commit 0c3541a

Please sign in to comment.