reportable 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/HISTORY.md +5 -0
- data/README.md +1 -1
- data/lib/saulabs/reportable.rb +9 -8
- metadata +1 -1
data/HISTORY.md
CHANGED
data/README.md
CHANGED
@@ -22,7 +22,7 @@ the number of updated users records per second or the number of registrations of
|
|
22
22
|
|
23
23
|
reportable :last_name_starting_with_a_registrations, :aggregation => :count, :grouping => :month, :conditions => ["last_name LIKE 'A%'"]
|
24
24
|
|
25
|
-
reportable :updated_per_second, :aggregation => :count, :grouping => :
|
25
|
+
reportable :updated_per_second, :aggregation => :count, :grouping => :hour, :date_column => :updated_at
|
26
26
|
|
27
27
|
end
|
28
28
|
|
data/lib/saulabs/reportable.rb
CHANGED
@@ -44,14 +44,15 @@ module Saulabs
|
|
44
44
|
# end
|
45
45
|
def reportable(name, options = {})
|
46
46
|
(class << self; self; end).instance_eval do
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
47
|
+
report_klass = if options.delete(:cumulate)
|
48
|
+
Saulabs::Reportable::CumulatedReport
|
49
|
+
else
|
50
|
+
Saulabs::Reportable::Report
|
51
|
+
end
|
52
|
+
define_method("#{name.to_s}_report".to_sym) do |*args|
|
53
|
+
report = report_klass.new(self, name, options)
|
54
|
+
raise ArgumentError.new unless args.empty? || (args.length == 1 && args.first.is_a?(Hash))
|
55
|
+
report.run(args.first || {})
|
55
56
|
end
|
56
57
|
end
|
57
58
|
end
|