Class: BestBoy::MonthReport
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- BestBoy::MonthReport
- Includes:
- ObeysTestMode, Reporting
- Defined in:
- app/models/best_boy/month_report.rb
Class Method Summary collapse
- .create_for(owner, type, source = nil, date = Time.zone.now) ⇒ Object
- .monthly_occurrences_for(owner, type, source = nil, date) ⇒ Object
- .overall_occurrences_for(owner, type, source = nil) ⇒ Object
- .yearly_occurrences_for(owner, type, source = nil, date) ⇒ Object
Methods included from ObeysTestMode
Class Method Details
.create_for(owner, type, source = nil, date = Time.zone.now) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'app/models/best_boy/month_report.rb', line 40 def create_for(owner, type, source = nil, date = Time.zone.now) month_report = BestBoy::MonthReport.new month_report.owner_type = owner.to_s month_report.event = type month_report.event_source = source month_report.created_at = date || Time.zone.now month_report.save ? month_report : nil end |
.monthly_occurrences_for(owner, type, source = nil, date) ⇒ Object
50 51 52 |
# File 'app/models/best_boy/month_report.rb', line 50 def monthly_occurrences_for(owner, type, source = nil, date) MonthReport.for(owner, type, source).between(date.beginning_of_month, date.end_of_month).sum(:occurrences) end |
.overall_occurrences_for(owner, type, source = nil) ⇒ Object
58 59 60 |
# File 'app/models/best_boy/month_report.rb', line 58 def overall_occurrences_for(owner, type, source = nil) MonthReport.for(owner, type, source).sum(:occurrences) end |
.yearly_occurrences_for(owner, type, source = nil, date) ⇒ Object
54 55 56 |
# File 'app/models/best_boy/month_report.rb', line 54 def yearly_occurrences_for(owner, type, source = nil, date) MonthReport.for(owner, type, source).between(date.beginning_of_year, date).sum(:occurrences) end |