class Bidu::House::ErrorReport
  include ConcernBuilder::OptionsParser

  delegate :period, :threshold, :scope, :clazz, :external_key, :id, to: :options_object

  def initialize(options)
    @options = {
      external_key: :id
    }.merge(options)
  end

  def status
    @status ||= error? ? :error : :ok
  end

  def percentage
    @percentage ||= last_entires.percentage(scope)
  end

  def scoped
    @scoped ||= last_entires.public_send(scope)
  end

  def error?
    percentage > threshold
  end

  def as_json
    {
      ids: scoped.map(&external_key),
      percentage: percentage
    }
  end

  private

  def last_entires
    @last_entires ||= clazz.where('updated_at >= ?', period.seconds.ago)
  end
end

class Bidu::House::ErrorReport
  include ConcernBuilder::OptionsParser

  delegate :period, :threshold, :scope, :clazz, :external_key, :id, to: :options_object

  def initialize(options)
    @options = {
      external_key: :id,
      threshold: 0.02,
      period: 1.day
    }.merge(options)
  end

  def status
    @status ||= error? ? :error : :ok
  end

  def percentage
    @percentage ||= last_entires.percentage(scope)
  end

  def scoped
    @scoped ||= last_entires.public_send(scope)
  end

  def error?
    percentage > threshold
  end

  def as_json
    {
      ids: scoped.map(&external_key),
      percentage: percentage
    }
  end

  private

  def last_entires
    @last_entires ||= clazz.where('updated_at >= ?', period.seconds.ago)
  end
end

Add default values to report config
Add default values to report config
