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 7b812ba
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions app/controllers/concerns/blacklight/search_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Blacklight::SearchContext

class_methods do
# Save the submitted search parameters in the search session
def record_search_parameters opts = { only: :index }
def record_search_parameters(opts = { unless: proc { |c| (c.action_name.to_s != "index") || c.send(:skip_session_tracking?) } })
before_action :set_current_search_session, opts
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 @@ -80,10 +80,17 @@ def agent_is_crawler?
end

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

skip_session_proc.call(request, params)
skip_session_proc = blacklight_config.skip_session_tracking
case skip_session_proc
when TrueClass
true
when Proc
skip_session_proc.call(request, params)
else
false
end
end

def find_or_initialize_search_session_from_params params
Expand Down

0 comments on commit 7b812ba

Please sign in to comment.