debian-mirror-gitlab/app/models/clusters/agents/activity_event.rb

40 lines
942 B
Ruby
Raw Normal View History

2022-01-26 12:08:38 +05:30
# frozen_string_literal: true
module Clusters
module Agents
class ActivityEvent < ApplicationRecord
2022-03-02 08:16:31 +05:30
include EachBatch
2022-01-26 12:08:38 +05:30
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) }
2022-03-02 08:16:31 +05:30
scope :recorded_before, -> (cutoff) { where('recorded_at < ?', cutoff) }
2022-01-26 12:08:38 +05:30
validates :recorded_at, :kind, :level, presence: true
nullify_if_blank :detail
enum kind: {
token_created: 0,
token_revoked: 1,
agent_connected: 2,
agent_disconnected: 3
}, _prefix: true
enum level: {
debug: 0,
info: 1,
warn: 2,
error: 3,
fatal: 4,
unknown: 5
}, _prefix: true
end
end
end