Class: SearchHistory

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/search_history.rb

Class Method Summary collapse

Class Method Details

.not_found_query(number, duration = 1.year.ago) ⇒ Object



8
9
10
# File 'app/models/search_history.rb', line 8

def self.not_found_query(number, duration = 1.year.ago)
  self.not_found.where('created_at > ?', duration).all.collect(&:query).inject(Hash.new(0)){|r,e| r[e] += 1; r}.to_a.collect{|q| q if q[1] >= number.to_i}.compact
end

.remove_all_history(user) ⇒ Object



12
13
14
# File 'app/models/search_history.rb', line 12

def self.remove_all_history(user)
  user.search_histories.update_all(user_id: nil)
end