Closed nikhilmat closed 9 years ago
Going to look like this:
class RedisAggregator < BrokenRecord::ResultAggregator
REDIS_KEY = "broken_record_#{Rails.env}"
def clear_redis!
$redis.keys("#{REDIS_KEY}*").each { |key| $redis.del(key) }
end
def report_results(klass)
redis = Redis::Namespace.new("#{REDIS_KEY}:#{klass.name}", redis: $redis)
all_errors = @aggregated_results[klass].map(&:errors).flatten
start_time = @aggregated_results[klass].map(&:start_time).min
end_time = @aggregated_results[klass].map(&:end_time).max
duration = (end_time - start_time).round(3)
redis.set 'duration', duration
redis.rpush 'errors', *all_errors if all_errors.present?
end
end
Turns out, we don't need to use this - we're going to look at your pretty output @nickgervasi :)
I'll leave this up if you want the change, but if I don't hear otherwise will close.
We're planning to subclass
BrokenRecord::ResultAggregator
and override the print results to put the data in redis for in app consumption