Class: Workarea::Metrics::SearchByDay

Inherits:
Object
  • Object
show all
Includes:
ByDay
Defined in:
app/models/workarea/metrics/search_by_day.rb

Class Method Summary collapse

Methods included from Mongoid::Document

#embedded_children

Class Method Details

.save_search(query_string, total_results, at: Time.current) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/workarea/metrics/search_by_day.rb', line 24

def self.save_search(query_string, total_results, at: Time.current)
  query_string = QueryString.new(query_string)
  return if query_string.id.blank? || query_string.short? || total_results.blank?

  inc(
    key: { query_id: query_string.id },
    set: { total_results: total_results.to_i, query_string: query_string.pretty },
    at: at,
    searches: 1
  )
end