Introduction
Introduction Statistics Contact Development Disclaimer Help
the Report#run method only accepts :conditions and _limit options - reportable …
Log
Files
Refs
README
---
commit 2d19c69d72d105e1ceceef35ba963c309b477fb2
parent 6a2014d4aef05d98e682c1f0db51caa6e885be45
Author: marcoow <[email protected]>
Date: Fri, 5 Dec 2008 23:56:16 +0800
the Report#run method only accepts :conditions and _limit options
Signed-off-by: Marco Otte-Witte <[email protected]>
Diffstat:
M lib/kvlr/reports_as_sparkline/repo… | 9 ++++-----
M lib/kvlr/reports_as_sparkline/repo… | 3 ++-
M spec/other/cumulated_report_spec.rb | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/lib/kvlr/reports_as_sparkline/report.rb b/lib/kvlr/reports_as_spar…
@@ -11,7 +11,7 @@ module Kvlr #:nodoc:
@klass = klass
@name = name
@date_column_name = (options[:date_column_name] || 'created_at').to_s
- @value_column_name = (options[:value_column_name] || (options[:aggrega…
+ @value_column_name = (options[:value_column_name] || (options[:aggrega…
@aggregation = options[:aggregation] || :count
@grouping = Grouping.new(options[:grouping] || :day)
@options = {
@@ -19,13 +19,12 @@ module Kvlr #:nodoc:
:conditions => options[:conditions] || ['']
}
@options.merge!(options)
- @options[:conditions][0].freeze
end
def run(options = {})
ensure_valid_options(options)
- options = @options.merge(options)
- ReportCache.cached_transaction(self, options[:limit]) do |begin_at|
+ ReportCache.cached_transaction(self, options, options.key?(:conditions…
+ options = @options.merge(options)
conditions = setup_conditions(begin_at, options[:conditions])
@klass.send(@aggregation,
@value_column_name,
@@ -52,7 +51,7 @@ module Kvlr #:nodoc:
conditions << begin_at
end
- def ensure_valid_options(options)
+ def ensure_valid_options(options, context = :initialize)
options.each_key do |k|
raise ArgumentError.new("Invalid option #{k}") unless [:limit, :ag…
end
diff --git a/lib/kvlr/reports_as_sparkline/report_cache.rb b/lib/kvlr/reports_a…
@@ -4,8 +4,9 @@ module Kvlr #:nodoc:
class ReportCache < ActiveRecord::Base
- def self.cached_transaction(report, limit, &block)
+ def self.cached_transaction(report, limit, no_cache = false, &block)
raise ArgumentError.new('A block must be given') unless block_given?
+ return yield(report.grouping.first_reporting_period(limit)) if no_cache
self.transaction do
cached_data = self.find(
:all,
diff --git a/spec/other/cumulated_report_spec.rb b/spec/other/cumulated_report_…
@@ -6,7 +6,7 @@ describe Kvlr::ReportsAsSparkline::CumulatedReport do
@report = Kvlr::ReportsAsSparkline::CumulatedReport.new(User, :cumulated_r…
end
- describe '#run' do
+ describe '.run' do
describe do
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.