Introduction
Introduction Statistics Contact Development Disclaimer Help
made ReportCache write a new cache entry for the last reporting period to read …
Log
Files
Refs
README
---
commit 3ebb3b9e324bd9dde944cd37855be48c8801e9b6
parent 4aa4217ae76fc2852ede223de89beb5dbfe2ceff
Author: marcoow <[email protected]>
Date: Tue, 16 Dec 2008 03:04:10 +0800
made ReportCache write a new cache entry for the last reporting period to read …
Signed-off-by: Marco Otte-Witte <[email protected]>
Diffstat:
M lib/kvlr/reports_as_sparkline/repo… | 30 +++++++++++++++++++--------…
1 file changed, 19 insertions(+), 11 deletions(-)
---
diff --git a/lib/kvlr/reports_as_sparkline/report_cache.rb b/lib/kvlr/reports_a…
@@ -36,28 +36,36 @@ module Kvlr #:nodoc:
reporting_period = ReportingPeriod.new(report.grouping)
while reporting_period != last_reporting_period_to_read
data = new_data.detect { |data| data[0] == reporting_period }
- cached = self.new(
- :model_name => report.klass.to_s,
- :report_name => report.name.to_s,
- :grouping => report.grouping.identifier.to_s,
- :aggregation => report.aggregation.to_s,
- :reporting_period => reporting_period.date_time,
- :value => (data ? data[1] : 0.0)
- )
+ cached = build_cached_data(report, reporting_period, data ? data[1…
cached.save! unless no_cache
result << [reporting_period.date_time, cached.value]
reporting_period = reporting_period.previous
end
data = (new_data.first && new_data.first[0] == last_reporting_period…
unless no_cache
- cached = cached_data.last || nil
- cached.update_attributes!(:value => data[1]) unless cached.nil? ||…
+ if data && cached = cached_data.last
+ cached.update_attributes!(:value => data[1])
+ else
+ cached = build_cached_data(report, last_reporting_period_to_read…
+ cached.save!
+ result << [last_reporting_period_to_read.date_time, cached.value]
+ end
end
- result << [last_reporting_period_to_read.date_time, data ? data[1] :…
result += (cached_data.map { |cached| [cached.reporting_period, cach…
result
end
+ def self.build_cached_data(report, reporting_period, value)
+ self.new(
+ :model_name => report.klass.to_s,
+ :report_name => report.name.to_s,
+ :grouping => report.grouping.identifier.to_s,
+ :aggregation => report.aggregation.to_s,
+ :reporting_period => reporting_period.date_time,
+ :value => value
+ )
+ end
+
end
end
You are viewing proxied material from jay.scot. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.