Skip to content

Commit

Permalink
SearchContext#.skip_session_tracking? delegates to #agent_is_crawler?
Browse files Browse the repository at this point in the history
  • Loading branch information
barmintor committed May 5, 2022
1 parent 0220177 commit 2ef9883
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions app/controllers/concerns/blacklight/search_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Blacklight::SearchContext
class_methods do
# Save the submitted search parameters in the search session
def record_search_parameters opts = { only: :index }
before_action :set_current_search_session, opts
before_action :set_current_search_session, opts.merge(unless: proc { |c| c.send :skip_session_tracking? })
end
end

Expand All @@ -39,7 +39,7 @@ def set_current_search_session
end

def find_search_session
if agent_is_crawler? || skip_session_tracking?
if skip_session_tracking?
nil
elsif params[:search_context].present?
find_or_initialize_search_session_from_params JSON.parse(params[:search_context])
Expand Down Expand Up @@ -81,9 +81,14 @@ def agent_is_crawler?

def skip_session_tracking?
skip_session_proc = blacklight_config.skip_session_tracking
return false if skip_session_proc.nil?

skip_session_proc.call(request, params)
case skip_session_proc
when TrueClass
true
when Proc
skip_session_proc.call(request, params)
else
agent_is_crawler?
end
end

def find_or_initialize_search_session_from_params params
Expand Down

0 comments on commit 2ef9883

Please sign in to comment.