Sha256: f4eb3f56a4efa36e15b812a4b4439b0c4d9ccec4e4310be559f55a7f1e83a3f6
Contents?: true
Size: 586 Bytes
Versions: 54
Compression:
Stored size: 586 Bytes
Contents
# frozen_string_literal: true class Search < ApplicationRecord belongs_to :user, optional: true serialize :query_params # A Search instance is considered a saved search if it has a user_id. def saved? user_id? end # delete old, unsaved searches def self.delete_old_searches(days_old) raise ArgumentError, 'days_old is expected to be a number' unless days_old.is_a?(Numeric) raise ArgumentError, 'days_old is expected to be greater than 0' if days_old <= 0 where(['created_at < ? AND user_id IS NULL', Time.zone.today - days_old]).delete_all end end
Version data entries
54 entries across 54 versions & 1 rubygems