Sha256: 3b7b8c82ce4e2b8019e66a19902d687c9b7c876c88200d43174cf9067ac06470

Contents?: true

Size: 788 Bytes

Versions: 18

Compression:

Stored size: 788 Bytes

Contents

# -*- encoding : utf-8 -*-
class Search < ActiveRecord::Base

  belongs_to :user

  serialize :query_params

  if Blacklight::Utils.needs_attr_accessible?
    attr_accessible :query_params 
  end

  unless respond_to?(:none)
    # polyfill
    scope :none, -> { where(id: nil).where("id IS NOT ?", nil) }
  end

  # A Search instance is considered a saved search if it has a user_id.
  def saved?
    self.user_id?
  end
  
  # delete old, unsaved searches
  def self.delete_old_searches(days_old)
    raise ArgumentError.new('days_old is expected to be a number') unless days_old.is_a?(Numeric)
    raise ArgumentError.new('days_old is expected to be greater than 0') if days_old <= 0
    self.destroy_all(['created_at < ? AND user_id IS NULL', Time.zone.today - days_old])
  end
  
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
blacklight-5.19.2 app/models/search.rb
blacklight-5.19.1 app/models/search.rb
blacklight-5.19.0 app/models/search.rb
blacklight-5.18.0 app/models/search.rb
blacklight-5.17.2 app/models/search.rb
blacklight-5.17.1 app/models/search.rb
blacklight-5.17.0 app/models/search.rb
blacklight-5.16.4 app/models/search.rb
blacklight-6.0.0.pre3 app/models/search.rb
blacklight-5.16.3 app/models/search.rb
blacklight-5.16.2 app/models/search.rb
blacklight-5.16.1 app/models/search.rb
blacklight-6.0.0.pre2 app/models/search.rb
blacklight-6.0.0.pre1 app/models/search.rb
blacklight-5.16.0 app/models/search.rb
blacklight-5.15.0 app/models/search.rb
blacklight-5.14.0 app/models/search.rb
blacklight-5.13.1 app/models/search.rb