Class: Chronicle::ErrorLog

Inherits:
ApplicationRecord show all
Defined in:
app/models/chronicle/error_log.rb

Constant Summary collapse

OPEN =

Constants are re-exported so callers can reference ErrorLog::OPEN etc. without knowing about the group model.

ErrorGroup::OPEN
RESOLVED =
ErrorGroup::RESOLVED
IGNORED =
ErrorGroup::IGNORED
VALID_STATUSES =
ErrorGroup::VALID_STATUSES

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cleaned_backtraceObject



35
# File 'app/models/chronicle/error_log.rb', line 35

def cleaned_backtrace  = error_group&.cleaned_backtrace  || @cleaned_backtrace

#error_fingerprintObject



33
# File 'app/models/chronicle/error_log.rb', line 33

def error_fingerprint = error_group&.fingerprint       || @error_fingerprint

#error_messageObject



32
# File 'app/models/chronicle/error_log.rb', line 32

def error_message     = error_group&.error_message     || @error_message

#original_backtraceObject



34
# File 'app/models/chronicle/error_log.rb', line 34

def original_backtrace = error_group&.original_backtrace || @original_backtrace

#projectObject

Reader methods: prefer the persisted group value once the log is saved; fall back to the in-memory virtual attribute during the create flow.



29
# File 'app/models/chronicle/error_log.rb', line 29

def project           = error_group&.project           || @project

#source_nameObject



31
# File 'app/models/chronicle/error_log.rb', line 31

def source_name       = error_group&.source_name       || @source_name

#source_typeObject



30
# File 'app/models/chronicle/error_log.rb', line 30

def source_type       = error_group&.source_type       || @source_type

Instance Method Details

#as_json(_options = {}) ⇒ Object



57
58
59
# File 'app/models/chronicle/error_log.rb', line 57

def as_json(_options = {})
  get_hash
end

#get_hashObject

Returns a flat hash that combines the log’s own columns with the key group-level fields inlined for API convenience, plus the full nested group for clients that need it.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/models/chronicle/error_log.rb', line 40

def get_hash
  group = error_group
  attributes.symbolize_keys.merge(
    error_fingerprint: group&.fingerprint,
    project: group&.project,
    source_type: group&.source_type,
    source_name: group&.source_name,
    error_message: group&.error_message,
    original_backtrace: group&.original_backtrace,
    cleaned_backtrace: group&.cleaned_backtrace,
    status: group&.status,
    jira_link: group&.jira_link,
    error_group: group&.get_hash,
    user: (Chronicle.config.user_model&.find_by(id: user_id)&.try(:basic_info) if user_id.present?)
  )
end