Sha256: 5e2dea553ffae5c860abdf31c9ab3d53b77a6b205bc8708bba94d1533dc196be

Contents?: true

Size: 657 Bytes

Versions: 28

Compression:

Stored size: 657 Bytes

Contents

module Workarea
  module Admin
    module Insights
      class SegmentViewModel < ApplicationViewModel
        include InsightsDetails

        insights_scope -> { Metrics::SegmentByDay.by_segment(model.id) }

        add_sparkline :orders
        add_summaries :orders, :revenue, :average_order_value
        add_graph_data :orders, :revenue, :average_order_value

        def average_order_value
          return nil if orders.zero?
          revenue / orders.to_f
        end

        def previous_average_order_value
          return nil if previous_orders.zero?
          previous_revenue / previous_orders.to_f
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-admin-3.5.27 app/view_models/workarea/admin/insights/segment_view_model.rb
workarea-admin-3.5.26 app/view_models/workarea/admin/insights/segment_view_model.rb
workarea-admin-3.5.25 app/view_models/workarea/admin/insights/segment_view_model.rb
workarea-admin-3.5.23 app/view_models/workarea/admin/insights/segment_view_model.rb
workarea-admin-3.5.22 app/view_models/workarea/admin/insights/segment_view_model.rb
workarea-admin-3.5.21 app/view_models/workarea/admin/insights/segment_view_model.rb
workarea-admin-3.5.20 app/view_models/workarea/admin/insights/segment_view_model.rb
workarea-admin-3.5.19 app/view_models/workarea/admin/insights/segment_view_model.rb
workarea-admin-3.5.18 app/view_models/workarea/admin/insights/segment_view_model.rb
workarea-admin-3.5.17 app/view_models/workarea/admin/insights/segment_view_model.rb
workarea-admin-3.5.16 app/view_models/workarea/admin/insights/segment_view_model.rb
workarea-admin-3.5.15 app/view_models/workarea/admin/insights/segment_view_model.rb
workarea-admin-3.5.14 app/view_models/workarea/admin/insights/segment_view_model.rb
workarea-admin-3.5.13 app/view_models/workarea/admin/insights/segment_view_model.rb
workarea-admin-3.5.12 app/view_models/workarea/admin/insights/segment_view_model.rb
workarea-admin-3.5.11 app/view_models/workarea/admin/insights/segment_view_model.rb
workarea-admin-3.5.10 app/view_models/workarea/admin/insights/segment_view_model.rb
workarea-admin-3.5.9 app/view_models/workarea/admin/insights/segment_view_model.rb
workarea-admin-3.5.8 app/view_models/workarea/admin/insights/segment_view_model.rb
workarea-admin-3.5.7 app/view_models/workarea/admin/insights/segment_view_model.rb