Commit 7251ab41 authored by Alexandru Croitor's avatar Alexandru Croitor Committed by Pedro Pombeiro

Simplify recent Runner scope

parent 512b4f97
......@@ -60,7 +60,7 @@ module Ci
scope :active, -> { where(active: true) }
scope :paused, -> { where(active: false) }
scope :online, -> { where('contacted_at > ?', online_contact_time_deadline) }
scope :recent, -> { where('(contacted_at IS ? AND ci_runners.created_at > ?) OR contacted_at > ?', nil, 3.months.ago, 3.months.ago) }
scope :recent, -> { where('ci_runners.created_at > :date OR contacted_at > :date', date: 3.months.ago) }
# The following query using negation is cheaper than using `contacted_at <= ?`
# because there are less runners online than have been created. The
# resulting query is quickly finding online ones and then uses the regular
......
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