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/clusters/agent.rb')
-rw-r--r--app/models/clusters/agent.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/app/models/clusters/agent.rb b/app/models/clusters/agent.rb
index 98490a13351..79fc2b58237 100644
--- a/app/models/clusters/agent.rb
+++ b/app/models/clusters/agent.rb
@@ -5,6 +5,7 @@ module Clusters
self.table_name = 'cluster_agents'
INACTIVE_AFTER = 1.hour.freeze
+ ACTIVITY_EVENT_LIMIT = 200
belongs_to :created_by_user, class_name: 'User', optional: true
belongs_to :project, class_name: '::Project' # Otherwise, it will load ::Clusters::Project
@@ -36,8 +37,15 @@ module Clusters
requested_project == project
end
- def active?
- agent_tokens.where("last_used_at > ?", INACTIVE_AFTER.ago).exists?
+ def connected?
+ agent_tokens.active.where("last_used_at > ?", INACTIVE_AFTER.ago).exists?
+ end
+
+ def activity_event_deletion_cutoff
+ # Order is defined by the association
+ activity_events
+ .offset(ACTIVITY_EVENT_LIMIT - 1)
+ .pick(:recorded_at)
end
end
end