Class: BestBoy::DayReport
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- BestBoy::DayReport
- Includes:
- ObeysTestMode, Reporting
- Defined in:
- app/models/best_boy/day_report.rb
Class Method Summary collapse
- .create_for(owner, type, source = nil, date = Time.zone.now) ⇒ Object
- .daily_occurrences_for(owner, type, source = nil, date) ⇒ Object
- .weekly_occurrences_for(owner, type, source = nil) ⇒ 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 49 50 51 |
# File 'app/models/best_boy/day_report.rb', line 40 def create_for(owner, type, source = nil, date = Time.zone.now) month_report = BestBoy::MonthReport.current_or_create_for(owner, type, source, date) day_report = BestBoy::DayReport.new day_report.owner_type = owner day_report.event = type day_report.month_report_id = month_report.id day_report.event_source = source day_report.created_at = date day_report.save ? day_report : nil end |
.daily_occurrences_for(owner, type, source = nil, date) ⇒ Object
53 54 55 |
# File 'app/models/best_boy/day_report.rb', line 53 def daily_occurrences_for(owner, type, source = nil, date) created_on(date).for(owner, type, source).sum(:occurrences) end |
.weekly_occurrences_for(owner, type, source = nil) ⇒ Object
57 58 59 |
# File 'app/models/best_boy/day_report.rb', line 57 def weekly_occurrences_for(owner, type, source = nil) week.for(owner, type, source).sum(:occurrences) end |