Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/ci/runner.rb')
-rw-r--r--app/models/ci/runner.rb12
1 files changed, 3 insertions, 9 deletions
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb
index a541dca47de..432c3a408a9 100644
--- a/app/models/ci/runner.rb
+++ b/app/models/ci/runner.rb
@@ -1,8 +1,7 @@
# frozen_string_literal: true
module Ci
- class Runner < ApplicationRecord
- extend Gitlab::Ci::Model
+ class Runner < Ci::ApplicationRecord
include Gitlab::SQL::Pattern
include RedisCacheable
include ChronicDurationAttribute
@@ -12,6 +11,7 @@ module Ci
include FeatureGate
include Gitlab::Utils::StrongMemoize
include TaggableQueries
+ include Presentable
add_authentication_token_field :token, encrypted: :optional
@@ -61,13 +61,7 @@ module Ci
scope :paused, -> { where(active: false) }
scope :online, -> { where('contacted_at > ?', online_contact_time_deadline) }
scope :recent, -> { where('ci_runners.created_at > :date OR ci_runners.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
- # indexed search and rejects the ones that are in the previous set. If we
- # did `contacted_at <= ?` the query would effectively have to do a seq
- # scan.
- scope :offline, -> { where.not(id: online) }
+ scope :offline, -> { where(arel_table[:contacted_at].lteq(online_contact_time_deadline)) }
scope :not_connected, -> { where(contacted_at: nil) }
scope :ordered, -> { order(id: :desc) }