Class: Workarea::Insights::StarSearches
- Inherits:
-
Base
- Object
- Base
- Workarea::Insights::StarSearches
show all
- Defined in:
- app/models/workarea/insights/star_searches.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
.avg_conversion_rate_of_top_two_searches_deciles ⇒ Object
24
25
26
|
# File 'app/models/workarea/insights/star_searches.rb', line 24
def avg_conversion_rate_of_top_two_searches_deciles
Metrics::SearchByWeek.last_week.by_searches_percentile(81..100).avg(:conversion_rate)
end
|
.dashboards ⇒ Object
5
6
7
|
# File 'app/models/workarea/insights/star_searches.rb', line 5
def dashboards
%w(search)
end
|
.generate_results ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'app/models/workarea/insights/star_searches.rb', line 14
def generate_results
Metrics::SearchByWeek
.last_week
.by_searches_percentile(91..100)
.where(:conversion_rate.gt => avg_conversion_rate_of_top_two_searches_deciles)
.order_by(conversion_rate: :desc, searches: :desc, _id: :asc)
.limit(Workarea.config.insights_searches_list_max_results)
.to_a
end
|
.generate_weekly! ⇒ Object
9
10
11
12
|
# File 'app/models/workarea/insights/star_searches.rb', line 9
def generate_weekly!
results = generate_results
create!(results: results.map(&:as_document)) if results.present?
end
|