Class: Bidu::House::Report::Error

Inherits:
Bidu::House::Report show all
Defined in:
lib/bidu/house/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 Bidu::House::Report

#json

Instance Method Summary collapse

Methods inherited from Bidu::House::Report

#status

Constructor Details

#initialize(options) ⇒ Error

Returns a new instance of Error.



18
19
20
# File 'lib/bidu/house/report/error.rb', line 18

def initialize(options)
  super(DEFAULT_OPTION.merge(options))
end

Instance Method Details

#as_jsonObject



34
35
36
37
38
39
40
# File 'lib/bidu/house/report/error.rb', line 34

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

#error?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/bidu/house/report/error.rb', line 30

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

#percentageObject



22
23
24
# File 'lib/bidu/house/report/error.rb', line 22

def percentage
  @percentage ||= fetch_percentage
end

#scopedObject



26
27
28
# File 'lib/bidu/house/report/error.rb', line 26

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