Class: Workarea::Insights::LowAovCustomers
- Inherits:
-
Base
- Object
- Base
- Workarea::Insights::LowAovCustomers
show all
- Defined in:
- app/models/workarea/insights/low_aov_customers.rb
Class Method Summary
collapse
Methods inherited from Base
beginning_of_last_month, current, end_of_last_month, generate_daily!, generate_weekly!, #include?, #slug
#releasable?
assert_valid_config!, async, disable, enable, inline, #run_callbacks
#embedded_children
Class Method Details
.dashboards ⇒ Object
5
6
7
|
# File 'app/models/workarea/insights/low_aov_customers.rb', line 5
def dashboards
%w(people)
end
|
.find_results ⇒ Object
14
15
16
17
18
19
20
21
22
23
|
# File 'app/models/workarea/insights/low_aov_customers.rb', line 14
def find_results
Metrics::User
.with_purchases
.ordered_since(30.days.ago)
.by_orders_percentile(81..100)
.by_average_order_value_percentile(1..20)
.order_by(orders: :desc, average_order_value: :desc, id: :asc)
.limit(Workarea.config.insights_users_list_max_results)
.to_a
end
|
.generate_monthly! ⇒ Object
9
10
11
12
|
# File 'app/models/workarea/insights/low_aov_customers.rb', line 9
def generate_monthly!
results = find_results
create!(results: results.map(&:as_document)) if results.present?
end
|