Files
fizzy/app/models/user/searcher.rb
T
Donal McBreen 28efe28f24 Replace Search::Index with Search::Records
Lean on ActiveRecord models for searching and strip out the raw SQL.
Replaces the search_index_* tables with sharded search_records_* tables
as that allows us to use a Search::Record model name.

A Class is dynamically created for each record table shard so that we
and we can access it via the Search::Record.for_account(account_id)
method.
2025-11-17 09:12:40 -05:00

18 lines
440 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.results(query: 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