Introduction
Introduction Statistics Contact Development Disclaimer Help
Added :include option to allow conditions with joint tables - reportable - Fork…
Log
Files
Refs
README
---
commit ad7246944c072bd3fe1632a62eecacb4be1abbe0
parent 980da245617fbf79d79ad4e6fff71c4a131e083b
Author: Pedro Freitas <[email protected]>
Date: Tue, 19 Mar 2013 13:47:44 +0000
Added :include option to allow conditions with joint tables
Diffstat:
M lib/saulabs/reportable.rb | 1 +
M lib/saulabs/reportable/report.rb | 6 ++++--
M spec/classes/report_spec.rb | 6 +++---
3 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/lib/saulabs/reportable.rb b/lib/saulabs/reportable.rb
@@ -38,6 +38,7 @@ module Saulabs
# the number of reporting periods to get (see +:grouping+)
# @option options [Hash] :conditions ({})
# conditions like in +ActiveRecord::Base#find+; only records that ma…
+
# @option options [Boolean] :live_data (false)
# specifies whether data for the current reporting period is to be r…
# @option options [DateTime, Boolean] :end_date (false)
diff --git a/lib/saulabs/reportable/report.rb b/lib/saulabs/reportable/report.rb
@@ -69,6 +69,7 @@ module Saulabs
@options = {
:limit => options[:limit] || 100,
:distinct => options[:distinct] || false,
+ :include => options[:include] || [],
:conditions => options[:conditions] || [],
:grouping => Grouping.new(options[:grouping] || :day),
:live_data => options[:live_data] || false,
@@ -119,6 +120,7 @@ module Saulabs
@klass.send(@aggregation,
@value_column,
:conditions => conditions,
+ :include => options[:include],
:distinct => options[:distinct],
:group => options[:grouping].to_sql(@date_column),
:order => "#{options[:grouping].to_sql(@date_column)} ASC",
@@ -147,13 +149,13 @@ 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…
when :run
options.each_key do |k|
- raise ArgumentError.new("Invalid option #{k}!") unless [:limit…
+ raise ArgumentError.new("Invalid option #{k}!") unless [:limit…
end
end
raise ArgumentError.new('Options :live_data and :end_date may not bo…
diff --git a/spec/classes/report_spec.rb b/spec/classes/report_spec.rb
@@ -21,7 +21,7 @@ describe Saulabs::Reportable::Report do
it 'should process the data with the report cache' 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
@@ -30,7 +30,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 })
@@ -47,7 +47,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.