Commit 5bb7b196 authored by Allison Browne's avatar Allison Browne

Address CR feedback

parent e5ef10c6
......@@ -59,7 +59,7 @@ class CommitStatus < Ci::ApplicationRecord
scope :eager_load_pipeline, -> { eager_load(:pipeline, project: { namespace: :route }) }
scope :with_pipeline, -> { joins(:pipeline) }
scope :created_at_before, ->(date) { where('ci_builds.created_at < ?', date) }
scope :updated_at_before, ->(date) { where('updated_at < ?', date) }
scope :updated_at_before, ->(date) { where('ci_builds.updated_at < ?', date) }
scope :updated_before, ->(lookback:, timeout:) {
where('(ci_builds.created_at BETWEEN ? AND ?) AND (ci_builds.updated_at BETWEEN ? AND ?)', lookback, timeout, lookback, timeout)
}
......
......@@ -64,13 +64,10 @@ class StuckCiJobsWorker # rubocop:disable Scalability/IdempotentWorker
def running_timed_out_builds
if Feature.enabled?(:ci_new_query_for_running_stuck_jobs)
running_builds = Ci::Build.running.created_at_before(BUILD_RUNNING_OUTDATED_TIMEOUT.ago)
running_builds = Ci::Build.running.created_at_before(BUILD_RUNNING_OUTDATED_TIMEOUT.ago).order(created_at: :asc, project_id: :asc) # rubocop: disable CodeReuse/ActiveRecord
Ci::Build.id_in(running_builds).updated_at_before(BUILD_RUNNING_OUTDATED_TIMEOUT.ago)
else
Ci::Build.running.where( # rubocop: disable CodeReuse/ActiveRecord
'ci_builds.updated_at < ?',
BUILD_RUNNING_OUTDATED_TIMEOUT.ago
)
Ci::Build.running.updated_at_before(BUILD_RUNNING_OUTDATED_TIMEOUT.ago)
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment