Class: Saulabs::Reportable::ReportCache
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Saulabs::Reportable::ReportCache
- Defined in:
- lib/saulabs/reportable/report_cache.rb
Overview
The ReportCache
class is a regular ActiveRecord
model and represents cached results for single ReportingPeriods. ReportCache
instances are identified by the combination of model_name
, report_name
, grouping
, aggregation
and reporting_period
.
Class Method Summary collapse
-
.clear_for(klass, report) ⇒ Object
Clears the cache for the specified
klass
andreport
. -
.process(report, options, &block) ⇒ Array<Array<DateTime, Float>>
Processes the report using the respective cache.
Class Method Details
.clear_for(klass, report) ⇒ Object
Clears the cache for the specified klass
and report
29 30 31 32 33 34 |
# File 'lib/saulabs/reportable/report_cache.rb', line 29 def self.clear_for(klass, report) self.delete_all(:conditions => { :model_name => klass.name, :report_name => report.to_s }) end |
.process(report, options, &block) ⇒ Array<Array<DateTime, Float>>
Processes the report using the respective cache.
57 58 59 60 61 62 63 64 |
# File 'lib/saulabs/reportable/report_cache.rb', line 57 def self.process(report, , &block) raise ArgumentError.new('A block must be given') unless block_given? self.transaction do cached_data = read_cached_data(report, ) new_data = read_new_data(cached_data, , &block) prepare_result(new_data, cached_data, report, ) end end |