1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# frozen_string_literal: true
module Clusters
module Agents
class ActivityEvent < ApplicationRecord
include EachBatch
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) }
scope :recorded_before, -> (cutoff) { where('recorded_at < ?', cutoff) }
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
|