Introduction
Introduction Statistics Contact Development Disclaimer Help
some cleanup - closes #4 for now... - reportable - Fork of reportable required …
Log
Files
Refs
README
---
commit 1bee300b16dc0dcad74c6a22ec01f5946856a4ed
parent 778762e3e9e6da1647cab1cc335a026ca3de23e8
Author: Marco Otte-Witte <[email protected]>
Date: Wed, 29 Apr 2009 21:00:35 +0200
some cleanup - closes #4 for now...
Diffstat:
M lib/simplabs/reports_as_sparkline/… | 32 ++++++++++++++++++++-------…
1 file changed, 21 insertions(+), 11 deletions(-)
---
diff --git a/lib/simplabs/reports_as_sparkline/report_cache.rb b/lib/simplabs/r…
@@ -12,7 +12,7 @@ module Simplabs #:nodoc:
raise ArgumentError.new('A block must be given') unless block_given?
self.transaction do
cached_data = []
- first_reporting_period = ReportingPeriod.first(options[:grouping], (…
+ first_reporting_period = get_first_reporting_period(options)
last_reporting_period = options[:end_date] ? ReportingPeriod.new(opt…
if cache
@@ -20,13 +20,7 @@ module Simplabs #:nodoc:
first_cached_reporting_period = cached_data.empty? ? nil : Reporti…
last_cached_reporting_period = cached_data.empty? ? nil : Reportin…
end
-
- new_data = if !options[:live_data] && last_cached_reporting_period =…
- []
- else
- end_date = options[:live_data] ? nil : (options[:end_date] ? last_…
- yield((last_cached_reporting_period.next rescue first_reporting_pe…
- end
+ new_data = read_new_data(first_reporting_period, last_reporting_peri…
prepare_result(new_data, cached_data, report, options, cache)
end
@@ -38,7 +32,7 @@ module Simplabs #:nodoc:
new_data = new_data.map { |data| [ReportingPeriod.from_db_string(opt…
result = cached_data.map { |cached| [cached.reporting_period, cached…
last_reporting_period = ReportingPeriod.new(options[:grouping])
- reporting_period = cached_data.empty? ? ReportingPeriod.first(option…
+ reporting_period = cached_data.empty? ? get_first_reporting_period(o…
while reporting_period < (options[:end_date] ? ReportingPeriod.new(o…
cached = build_cached_data(report, options[:grouping], options[:li…
cached.save! if cache
@@ -85,14 +79,30 @@ module Simplabs #:nodoc:
conditions.first << ' AND reporting_period >= ?'
conditions << first_reporting_period.date_time
end
- self.find(
- :all,
+ self.all(
:conditions => conditions,
:limit => options[:limit],
:order => 'reporting_period ASC'
)
end
+ def self.read_new_data(first_reporting_period, last_reporting_period, …
+ if !options[:live_data] && last_cached_reporting_period == Reporting…
+ []
+ else
+ end_date = options[:live_data] ? nil : (options[:end_date] ? last_…
+ yield((last_cached_reporting_period.next rescue first_reporting_pe…
+ end
+ end
+
+ def self.get_first_reporting_period(options)
+ if options[:end_date]
+ ReportingPeriod.first(options[:grouping], options[:limit] - 1, opt…
+ else
+ ReportingPeriod.first(options[:grouping], options[:limit])
+ end
+ 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.