From 96b15cbba64f8c513fab992ae6b060b4fa2025f7 Mon Sep 17 00:00:00 2001
From: Neil Lalonde <neillalonde@gmail.com>
Date: Fri, 6 Feb 2015 17:20:11 -0500
Subject: [PATCH] FIX: dashboard report date range calculations include time
 zone, and application request data too

---
 app/models/application_request.rb | 6 +++---
 app/models/report.rb              | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/app/models/application_request.rb b/app/models/application_request.rb
index a178a0cf4..b0e0df278 100644
--- a/app/models/application_request.rb
+++ b/app/models/application_request.rb
@@ -15,7 +15,7 @@ class ApplicationRequest < ActiveRecord::Base
 
   # auto flush if older than this
   self.autoflush_seconds = 5.minutes
-  self.last_flush = Time.now
+  self.last_flush = Time.now.utc
 
   def self.increment!(type, opts=nil)
     key = redis_key(type)
@@ -28,7 +28,7 @@ class ApplicationRequest < ActiveRecord::Base
       return
     end
 
-    if (Time.now - last_flush).to_i > autoflush_seconds
+    if (Time.now.utc - last_flush).to_i > autoflush_seconds
       write_cache!
     end
   end
@@ -40,7 +40,7 @@ class ApplicationRequest < ActiveRecord::Base
       return
     end
 
-    self.last_flush = Time.now
+    self.last_flush = Time.now.utc
 
     date = date.to_date
 
diff --git a/app/models/report.rb b/app/models/report.rb
index 03092648e..3cc9f1c10 100644
--- a/app/models/report.rb
+++ b/app/models/report.rb
@@ -13,8 +13,8 @@ class Report
     @data = nil
     @total = nil
     @prev30Days = nil
-    @start_date ||= 1.month.ago.utc.beginning_of_day
-    @end_date ||= Time.now.utc.end_of_day
+    @start_date ||= 1.month.ago.beginning_of_day
+    @end_date ||= Time.zone.now.end_of_day
   end
 
   def as_json(options = nil)