Class: Workarea::Insights::NewProducts
- Inherits:
-
Base
- Object
- Base
- Workarea::Insights::NewProducts
show all
- Defined in:
- app/models/workarea/insights/new_products.rb
Class Method Summary
collapse
Methods inherited from Base
beginning_of_last_month, current, end_of_last_month, generate_monthly!, generate_weekly!, #include?, #slug
#releasable?
add_worker, assert_valid_config!, async, caching_classes?, disable, enable, inline, #run_callbacks, workers, workers_list
#embedded_children
Class Method Details
.beginning_of_yesteday ⇒ Object
23
24
25
|
# File 'app/models/workarea/insights/new_products.rb', line 23
def beginning_of_yesteday
Time.current.yesterday.beginning_of_day
end
|
.dashboards ⇒ Object
5
6
7
|
# File 'app/models/workarea/insights/new_products.rb', line 5
def dashboards
%w(catalog)
end
|
.end_of_yesterday ⇒ Object
27
28
29
|
# File 'app/models/workarea/insights/new_products.rb', line 27
def end_of_yesterday
Time.current.yesterday.end_of_day
end
|
.generate_daily! ⇒ Object
9
10
11
12
|
# File 'app/models/workarea/insights/new_products.rb', line 9
def generate_daily!
results = generate_results
create!(results: results) if results.present?
end
|
.generate_results ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'app/models/workarea/insights/new_products.rb', line 14
def generate_results
Catalog::Product
.where(:created_at.gte => beginning_of_yesteday)
.where(:created_at.lte => end_of_yesterday)
.order(created_at: :desc)
.limit(Workarea.config.insights_products_list_max_results)
.map { |result| { product_id: result['_id'] } }
end
|