4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/searchjoy/track.rb', line 4
def track
results = @execute
if options[:track] && !results.search
attributes = options[:track] == true ? {} : options[:track]
search_type =
if klass.respond_to?(:name) && klass.name.present?
klass.name
elsif options[:models]
Array(options[:models]).map(&:to_s).sort.join(" ")
elsif options[:index_name]
Array(options[:index_name]).map(&:to_s).sort.join(" ")
else
"All Indices"
end
results.search = Searchjoy::Search.create({search_type: search_type, query: term, results_count: results.total_count}.merge(attributes))
end
end
|