Class: Workarea::Insights::NonSellers
- Inherits:
-
Base
- Object
- Base
- Workarea::Insights::NonSellers
show all
- Defined in:
- app/models/workarea/insights/non_sellers.rb
Class Method Summary
collapse
Methods inherited from Base
beginning_of_last_month, current, end_of_last_month, generate_daily!, generate_monthly!, #include?, #slug
#releasable?
add_worker, assert_valid_config!, async, caching_classes?, disable, enable, inline, #run_callbacks, workers, workers_list
#embedded_children
Class Method Details
.dashboards ⇒ Object
5
6
7
|
# File 'app/models/workarea/insights/non_sellers.rb', line 5
def dashboards
%w(catalog)
end
|
.generate_results ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'app/models/workarea/insights/non_sellers.rb', line 14
def generate_results
Metrics::ProductByWeek
.last_week
.where(:orders.lt => 1, :views.gt => 0)
.order_by(views: :desc, _id: :asc)
.limit(Workarea.config.insights_products_list_max_results)
.to_a
end
|
.generate_weekly! ⇒ Object
9
10
11
12
|
# File 'app/models/workarea/insights/non_sellers.rb', line 9
def generate_weekly!
results = generate_results
create!(results: results.map(&:as_document)) if results.present?
end
|