Introduction
Introduction Statistics Contact Development Disclaimer Help
Merge :cacheable changes back in - reportable - Fork of reportable required by …
Log
Files
Refs
README
---
commit 833bedd80fe51828d065a33490979c39a69ce5a1
parent e2a282013a4ad968a58806bb0fc8e3efbab5bd8d
Author: HD Moore <[email protected]>
Date: Mon, 8 Sep 2014 01:19:24 -0500
Merge :cacheable changes back in
Diffstat:
M lib/saulabs/reportable/report.rb | 2 +-
M lib/saulabs/reportable/report_cach… | 10 +++++++---
M spec/classes/report_spec.rb | 6 +++---
3 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/lib/saulabs/reportable/report.rb b/lib/saulabs/reportable/report.rb
@@ -156,7 +156,7 @@ module Saulabs
case context
when :initialize
options.each_key do |k|
- raise ArgumentError.new("Invalid option #{k}!") unless [:limit…
+ raise ArgumentError.new("Invalid option #{k}!") unless [:limit…
end
raise ArgumentError.new("Invalid aggregation #{options[:aggregat…
raise ArgumentError.new('The name of the column holding the valu…
diff --git a/lib/saulabs/reportable/report_cache.rb b/lib/saulabs/reportable/re…
@@ -96,9 +96,12 @@ module Saulabs
if options[:cacheable] and cached = cached_data.find { |cached| re…
result << [cached[0].date_time, cached[1]]
elsif reporting_period.last_date_time.past?
- new_cached = build_cached_data(report, options[:grouping], optio…
- new_cached.save!
- result << [reporting_period.date_time, new_cached.value]
+ value = find_value(new_data, reporting_period)
+ if options[:cacheable]
+ new_cached = build_cached_data(report, options[:grouping], opt…
+ new_cached.save!
+ end
+ result << [reporting_period.date_time, value]
else
result << [reporting_period.date_time, find_value(new_data, repo…
end
@@ -138,6 +141,7 @@ module Saulabs
end
def self.read_cached_data(report, options)
+ return [] if not options[:cacheable]
conditions = build_conditions_for_reading_cached_data(report, option…
conditions.limit(options[:limit]).order('reporting_period ASC')
end
diff --git a/spec/classes/report_spec.rb b/spec/classes/report_spec.rb
@@ -22,7 +22,7 @@ describe Saulabs::Reportable::Report do
Saulabs::Reportable::ReportCache.should_receive(:process).once.with(
@report,
- { :limit => 100, :grouping => @report.options[:grouping], :conditions …
+ { :limit => 100, :grouping => @report.options[:grouping], :conditions …
)
@report.run
@@ -31,7 +31,7 @@ describe Saulabs::Reportable::Report do
it 'should process the data with the report cache when custom conditions a…
Saulabs::Reportable::ReportCache.should_receive(:process).once.with(
@report,
- { :limit => 100, :grouping => @report.options[:grouping], :conditions …
+ { :limit => 100, :grouping => @report.options[:grouping], :conditions …
)
@report.run(:conditions => { :some => :condition })
@@ -48,7 +48,7 @@ describe Saulabs::Reportable::Report do
Saulabs::Reportable::Grouping.should_receive(:new).once.with(:month).and…
Saulabs::Reportable::ReportCache.should_receive(:process).once.with(
@report,
- { :limit => 100, :grouping => grouping, :conditions => [], :live_data …
+ { :limit => 100, :grouping => grouping, :conditions => [], :live_data …
)
@report.run(:grouping => :month)
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.