Only cache results for reporting periods which are in the past. - reportable - Fork of reportable required by WarVox, from hdm/reportable.
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit d0baa6eb4e4a8330647bd6ff3f49df472f61188c
(DIR) parent 82ac39c518135608936c8780b1736801a982bb69
(HTM) Author: Dieter Komendera <dieter@komendera.com>
Date: Thu, 22 May 2014 11:52:21 +0200
Only cache results for reporting periods which are in the past.
Diffstat:
M lib/saulabs/reportable/report_cach… | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/lib/saulabs/reportable/report_cache.rb b/lib/saulabs/reportable/report_cache.rb
@@ -93,10 +93,12 @@ module Saulabs
while reporting_period < (options[:end_date] ? ReportingPeriod.new(options[:grouping], options[:end_date]).next : current_reporting_period)
if cached = cached_data.find { |cached| reporting_period == cached[0] }
result << [cached[0].date_time, cached[1]]
- else
+ elsif reporting_period.last_date_time.past?
new_cached = build_cached_data(report, options[:grouping], options[:conditions], reporting_period, find_value(new_data, reporting_period))
new_cached.save!
result << [reporting_period.date_time, new_cached.value]
+ else
+ result << [reporting_period.date_time, find_value(new_data, reporting_period)]
end
reporting_period = reporting_period.next
end