Fixed duplicate key sql error by preventing reporting_period from doing a time zone conversion. - reportable - Fork of reportable required by WarVox, from hdm/reportable.
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit fa8af89304d38318f6a2cb4f2b01a6f7f2e6bc7d
(DIR) parent 8791b1e44c216af03bcf53805cdfb642d49b20e0
(HTM) Author: Myron Marston <myron.marston@gmail.com>
Date: Mon, 4 May 2009 15:43:15 +0800
Fixed duplicate key sql error by preventing reporting_period from doing a time zone conversion.
Signed-off-by: Marco Otte-Witte <marco.otte-witte@simplabs.com>
Diffstat:
M lib/simplabs/reports_as_sparkline/… | 7 +++++++
1 file changed, 7 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/lib/simplabs/reports_as_sparkline/report_cache.rb b/lib/simplabs/reports_as_sparkline/report_cache.rb
@@ -8,6 +8,13 @@ module Simplabs #:nodoc:
set_table_name :reports_as_sparkline_cache
+ # When reporting_period has a time zone conversion performed, we get duplicate key sql errors.
+ # This occurs because find_cached_data will return a record set that is missing a record when we
+ # have an end date. The SQL criteria reporting_period BETWEEN before_date AND end_date will not include
+ # the last record that it should, because our end_date will not be time-zone converted (ex: 5/1/09 00:00:00) but
+ # the reported_period in the database will be time-zone converted (ex: 5/1/00 07:00:00).
+ self.skip_time_zone_conversion_for_attributes = [:reporting_period]
+
def self.process(report, options, cache = true, &block) #:nodoc:
raise ArgumentError.new('A block must be given') unless block_given?
self.transaction do