Files
Donal McBreen b571303385 Don't use Current.account for search records
It doesn't actually work, and even if we could make it work reliably
we are better off if the records always know to go to the right shard.

It does make the interface a bit more complicated as we need to select
the right shard class with `for(account_id)`.
2025-11-25 11:34:41 +00:00

18 lines
456 B
Ruby

module User::Searcher
extend ActiveSupport::Concern
included do
has_many :search_queries, class_name: "Search::Query", dependent: :destroy
end
def search(terms)
Search::Record.for(account_id).search(terms, user: self)
end
def remember_search(terms)
search_queries.find_or_create_by(terms: terms).tap do |search_query|
search_query.touch unless search_query.invalid? || search_query.previously_new_record?
end
end
end