Introduction
Introduction Statistics Contact Development Disclaimer Help
Merge pull request #28 from pelf/master - reportable - Fork of reportable requi…
Log
Files
Refs
README
---
commit 89f342b0eebca0d7331a8a652aa453de97715785
parent e84698645f207ecd889c79b76af56188b3456f24
Author: Martin Kvlr <[email protected]>
Date: Thu, 28 Mar 2013 04:34:04 -0700
Merge pull request #28 from pelf/master
Supports :include option for more elaborate report needs
Diffstat:
M generators/reportable_jquery_flot_… | 2 ++
M generators/reportable_raphael_asse… | 2 ++
M lib/saulabs/reportable.rb | 2 ++
M lib/saulabs/reportable/report.rb | 12 ++++++++----
M spec/classes/report_spec.rb | 6 +++---
5 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/generators/reportable_jquery_flot_assets/reportable_jquery_flot_as…
@@ -2,6 +2,8 @@ class ReportableJqueryFlotAssetsGenerator < Rails::Generators::…
include Rails::Generators::Actions
+ source_root File.expand_path('../templates/', __FILE__)
+
def create_jquery_flot_file
empty_directory('public/javascripts')
copy_file(
diff --git a/generators/reportable_raphael_assets/reportable_raphael_assets_gen…
@@ -2,6 +2,8 @@ class ReportableRaphaelAssetsGenerator < Rails::Generators::Base
include Rails::Generators::Actions
+ source_root File.expand_path('../templates/', __FILE__)
+
def create_raphael_file
empty_directory('public/javascripts')
copy_file(
diff --git a/lib/saulabs/reportable.rb b/lib/saulabs/reportable.rb
@@ -38,6 +38,8 @@ 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 [Hash] :include ({})
+ # include like in +ActiveRecord::Base#find+; names associations that…
# @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
@@ -54,6 +54,8 @@ module Saulabs
# the number of reporting periods to get (see +:grouping+)
# @option options [Hash] :conditions ({})
# conditions like in +ActiveRecord::Base#find+; only records that matc…
+ # @option options [Hash] :include ({})
+ # include like in +ActiveRecord::Base#find+; names associations that s…
# @option options [Boolean] :live_data (false)
# specifies whether data for the current reporting period is to be rea…
# @option options [DateTime, Boolean] :end_date (false)
@@ -69,6 +71,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,9 +122,10 @@ 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",
+ :group => options[:grouping].to_sql("#{ActiveRecord::Base.con…
+ :order => "#{options[:grouping].to_sql("#{ActiveRecord::Base.…
:limit => options[:limit]
)
end
@@ -147,13 +151,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.