Class: Mercy::Report::Error

Inherits:
ActiveRecord show all
Defined in:
lib/mercy/report/error.rb

Constant Summary collapse

ALLOWED_PARAMETERS =
[:period, :threshold]
DEFAULT_OPTION =
{
  external_key: :id,
  threshold: 0.02,
  period: 1.day,
  scope: :with_error,
  base_scope: :all,
  uniq: false
}

Instance Attribute Summary

Attributes inherited from Mercy::Report

#json

Instance Method Summary collapse

Methods inherited from Mercy::Report

#status

Constructor Details

#initialize(options) ⇒ Error

Returns a new instance of Error.



17
18
19
# File 'lib/mercy/report/error.rb', line 17

def initialize(options)
  super(self.class::DEFAULT_OPTION.merge(options))
end

Instance Method Details

#as_jsonObject



33
34
35
36
37
38
39
# File 'lib/mercy/report/error.rb', line 33

def as_json
  {
    ids: ids,
    percentage: percentage,
    status: status
  }
end

#error?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/mercy/report/error.rb', line 29

def error?
  @error ||= percentage > threshold
end

#percentageObject



21
22
23
# File 'lib/mercy/report/error.rb', line 21

def percentage
  @percentage ||= fetch_percentage
end

#scopedObject



25
26
27
# File 'lib/mercy/report/error.rb', line 25

def scoped
  @scoped ||= fetch_scoped(last_entries, scope)
end