Class: Bidu::House::ErrorReport
- Inherits:
-
Object
- Object
- Bidu::House::ErrorReport
- Includes:
- JsonParser
- Defined in:
- lib/bidu/house/error_report.rb
Instance Attribute Summary collapse
-
#json ⇒ Object
readonly
Returns the value of attribute json.
Instance Method Summary collapse
- #as_json ⇒ Object
- #error? ⇒ Boolean
-
#initialize(options) ⇒ ErrorReport
constructor
A new instance of ErrorReport.
- #percentage ⇒ Object
- #scoped ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(options) ⇒ ErrorReport
Returns a new instance of ErrorReport.
12 13 14 15 16 17 18 19 |
# File 'lib/bidu/house/error_report.rb', line 12 def initialize() @json = { external_key: :id, threshold: 0.02, period: 1.day, scope: :with_error }.merge() end |
Instance Attribute Details
#json ⇒ Object (readonly)
Returns the value of attribute json.
6 7 8 |
# File 'lib/bidu/house/error_report.rb', line 6 def json @json end |
Instance Method Details
#as_json ⇒ Object
37 38 39 40 41 42 |
# File 'lib/bidu/house/error_report.rb', line 37 def as_json { ids: scoped.pluck(external_key), percentage: percentage } end |
#error? ⇒ Boolean
33 34 35 |
# File 'lib/bidu/house/error_report.rb', line 33 def error? percentage > threshold end |
#percentage ⇒ Object
25 26 27 |
# File 'lib/bidu/house/error_report.rb', line 25 def percentage @percentage ||= last_entires.percentage(scope) end |
#scoped ⇒ Object
29 30 31 |
# File 'lib/bidu/house/error_report.rb', line 29 def scoped @scoped ||= last_entires.public_send(scope) end |
#status ⇒ Object
21 22 23 |
# File 'lib/bidu/house/error_report.rb', line 21 def status @status ||= error? ? :error : :ok end |