Class: Workarea::Insights::PopularSearchesWithoutResults

Inherits:
Base
  • Object
show all
Defined in:
app/models/workarea/insights/popular_searches_without_results.rb

Class Method Summary collapse

Methods inherited from Base

beginning_of_last_month, current, end_of_last_month, generate_daily!, generate_weekly!, #include?, #slug

Methods included from ApplicationDocument

#releasable?

Methods included from Sidekiq::Callbacks

add_worker, assert_valid_config!, async, caching_classes?, disable, enable, inline, #run_callbacks, workers, workers_list

Methods included from Mongoid::Document

#embedded_children

Class Method Details

.dashboardsObject



5
6
7
# File 'app/models/workarea/insights/popular_searches_without_results.rb', line 5

def dashboards
  %w(search)
end

.generate_monthly!Object



9
10
11
12
# File 'app/models/workarea/insights/popular_searches_without_results.rb', line 9

def generate_monthly!
  results = generate_results
  create!(results: results) if results.present?
end

.generate_resultsObject



14
15
16
# File 'app/models/workarea/insights/popular_searches_without_results.rb', line 14

def generate_results
  report.results.take(Workarea.config.insights_searches_list_max_results)
end

.reportObject



18
19
20
21
22
23
24
25
26
# File 'app/models/workarea/insights/popular_searches_without_results.rb', line 18

def report
  Reports::Searches.new(
    starts_at: beginning_of_last_month,
    ends_at: end_of_last_month,
    results_filter: 'without_results',
    sort_by: 'searches',
    sort_direction: 'desc'
  )
end