diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-24 00:10:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-24 00:10:02 +0300 |
commit | abd24a801e8dbe0942558dd2b2cad90e7e01938e (patch) | |
tree | 27b00caff863be07505fa60e63ece1d55f10e2b9 /app/models/clusters | |
parent | fee19ef336bc64155e0d9e8697834ff529bb6d93 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/clusters')
-rw-r--r-- | app/models/clusters/agent.rb | 2 | ||||
-rw-r--r-- | app/models/clusters/agents/activity_event.rb | 34 |
2 files changed, 36 insertions, 0 deletions
diff --git a/app/models/clusters/agent.rb b/app/models/clusters/agent.rb index cf6d95fc6df..f04ac6f1722 100644 --- a/app/models/clusters/agent.rb +++ b/app/models/clusters/agent.rb @@ -16,6 +16,8 @@ module Clusters has_many :project_authorizations, class_name: 'Clusters::Agents::ProjectAuthorization' has_many :authorized_projects, class_name: '::Project', through: :project_authorizations, source: :project + has_many :activity_events, -> { in_timeline_order }, class_name: 'Clusters::Agents::ActivityEvent', inverse_of: :agent + scope :ordered_by_name, -> { order(:name) } scope :with_name, -> (name) { where(name: name) } diff --git a/app/models/clusters/agents/activity_event.rb b/app/models/clusters/agents/activity_event.rb new file mode 100644 index 00000000000..668aba74821 --- /dev/null +++ b/app/models/clusters/agents/activity_event.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module Clusters + module Agents + class ActivityEvent < ApplicationRecord + include NullifyIfBlank + + self.table_name = 'agent_activity_events' + + belongs_to :agent, class_name: 'Clusters::Agent', optional: false + belongs_to :user + belongs_to :agent_token, class_name: 'Clusters::AgentToken' + + scope :in_timeline_order, -> { order(recorded_at: :desc, id: :desc) } + + validates :recorded_at, :kind, :level, presence: true + + nullify_if_blank :detail + + enum kind: { + token_created: 0 + }, _prefix: true + + enum level: { + debug: 0, + info: 1, + warn: 2, + error: 3, + fatal: 4, + unknown: 5 + }, _prefix: true + end + end +end |