From e61a28f3e106b853691d63acfd17681ef16ffd68 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 4 Apr 2013 13:29:54 +1100 Subject: [PATCH] utc vs non utc is a subtle issue, tests were failing for a few hours every day cause of this --- app/models/report.rb | 7 +++++-- spec/models/report_spec.rb | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/models/report.rb b/app/models/report.rb index ad1ba24cbb0..f806a1dc889 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -75,8 +75,11 @@ class Report def self.report_flags(report) report.data = [] (0..30).to_a.reverse.each do |i| - if (count = PostAction.where('date(created_at) = ?', i.days.ago.to_date).where(post_action_type_id: PostActionType.flag_types.values).count) > 0 - report.data << {x: i.days.ago.to_date.to_s, y: count} + count = PostAction.where('date(created_at) = ?', i.days.ago.utc.to_date) + .where(post_action_type_id: PostActionType.flag_types.values) + .count + if count > 0 + report.data << {x: i.days.ago.utc.to_date.to_s, y: count} end end flagsQuery = PostAction.where(post_action_type_id: PostActionType.flag_types.values) diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rb index 0285ab98b1e..655e9cf3614 100644 --- a/spec/models/report_spec.rb +++ b/spec/models/report_spec.rb @@ -140,4 +140,4 @@ describe Report do end end -end \ No newline at end of file +end