Skip to content

Commit

Permalink
Move licence finder check to model
Browse files Browse the repository at this point in the history
Allows us to check for the licence finder beyond the QueryBuilder class.
The ContentItem model also seems a more appropriate place to verfiy the
exact finder content item..
  • Loading branch information
1pretz1 committed Jun 30, 2023
1 parent 87fdc52 commit a45ed6b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 3 additions & 7 deletions app/lib/search/query_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def remove_stopwords?
end

def stopwords_for_path
licence_transaction_path? ? LICENCE_STOPWORDS : []
finder_content_item.is_licence_transaction? ? LICENCE_STOPWORDS : []
end

def remove_stopwords
Expand Down Expand Up @@ -243,7 +243,7 @@ def ab_query
# We're using the ab test relevance:disable params here to turn off LTR for this
# finder. It would probably be best in the long run to create a specific way of
# doing this that uses a proper parameter, but we can't do that at the moment.
ab_params.merge!("relevance" => "disable") if licence_transaction_path? && !force_ltr?
ab_params.merge!("relevance" => "disable") if finder_content_item.is_licence_transaction? && !force_ltr?
ab_params.any? ? { "ab_tests" => ab_params.map { |k, v| "#{k}:#{v}" }.join(",") } : {}
end

Expand All @@ -252,15 +252,11 @@ def suggest_query
end

def boost_fields_query
return {} unless licence_transaction_path?
return {} unless finder_content_item.is_licence_transaction?

{ "boost_fields" => "licence_transaction_industry" }
end

def licence_transaction_path?
finder_content_item.base_path == "/find-licences"
end

def force_ltr?
params["force-ltr"] == "true"
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/content_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ def government_content_section
base_path.split("/")[2]
end

def is_licence_transaction?
base_path == "/find-licences"
end

private

attr_reader :content_item_hash
Expand Down

0 comments on commit a45ed6b

Please sign in to comment.