Module: Workarea::Admin::Insights::InsightsDetails
- Extended by:
- ActiveSupport::Concern
- Includes:
- CalculatePercentChange
- Included in:
- CategoryViewModel, DiscountViewModel, ProductViewModel, SearchViewModel, SegmentViewModel
- Defined in:
- app/view_models/workarea/admin/insights/insights_details.rb
Instance Method Summary collapse
- #current_period ⇒ Object
- #ends_at ⇒ Object
- #previous_ends_at ⇒ Object
- #previous_period ⇒ Object
- #previous_starts_at ⇒ Object
- #starts_at ⇒ Object
Instance Method Details
#current_period ⇒ Object
69 70 71 72 73 |
# File 'app/view_models/workarea/admin/insights/insights_details.rb', line 69 def current_period @current_period ||= instance_exec(&insights_scoping) .by_date_range(starts_at: starts_at, ends_at: ends_at) .to_a end |
#ends_at ⇒ Object
57 58 59 |
# File 'app/view_models/workarea/admin/insights/insights_details.rb', line 57 def ends_at @ends_at ||= Time.zone.parse([:ends_at].to_s) || Time.current rescue Time.current end |
#previous_ends_at ⇒ Object
65 66 67 |
# File 'app/view_models/workarea/admin/insights/insights_details.rb', line 65 def previous_ends_at @previous_ends_at ||= (starts_at - 1.day).end_of_day end |
#previous_period ⇒ Object
75 76 77 78 79 |
# File 'app/view_models/workarea/admin/insights/insights_details.rb', line 75 def previous_period @previous_period ||= instance_exec(&insights_scoping) .by_date_range(starts_at: previous_starts_at, ends_at: previous_ends_at) .to_a end |
#previous_starts_at ⇒ Object
61 62 63 |
# File 'app/view_models/workarea/admin/insights/insights_details.rb', line 61 def previous_starts_at @previous_starts_at ||= starts_at - (ends_at - starts_at).seconds - 1.day end |
#starts_at ⇒ Object
52 53 54 55 |
# File 'app/view_models/workarea/admin/insights/insights_details.rb', line 52 def starts_at default = Workarea.config.reports_default_starts_at.call @starts_at ||= Time.zone.parse([:starts_at].to_s) || default rescue default end |