app/models/errdo/error_occurrence.rb in errdo-0.12.7 vs app/models/errdo/error_occurrence.rb in errdo-0.12.8

- old
+ new

@@ -11,9 +11,15 @@ belongs_to :experiencer, polymorphic: true after_create :update_last_occurrence after_create :update_last_experiencer + def self.grouped_by_time(timeframe = nil) + errors = Errdo::ErrorOccurrence.where("created_at > ?", 2.weeks.ago) + timeframe = useful_time(Time.now - errors.first.created_at) if timeframe.nil? + hist(errors, 24, Time.now - timeframe, timeframe) + end + private def update_last_occurrence error.update(last_occurred_at: created_at) if error && !created_at.nil? end