Skip to content

Commit

Permalink
Make serving config optionally dynamic
Browse files Browse the repository at this point in the history
This adds the ability to switch to a different serving config from the
default one using a `serving_config` query parameter.

This will allow us to build a feature in Finder Frontend for internal
users to preview changes to serving configs.
  • Loading branch information
csutter committed Feb 7, 2025
1 parent 4d6e809 commit 36fbdd9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/services/discovery_engine/query/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ def query
end

def serving_config
ServingConfig.default.name
return ServingConfig.default.name if query_params[:serving_config].blank?

ServingConfig.new(query_params[:serving_config]).name
end

def page_size
Expand Down
10 changes: 10 additions & 0 deletions spec/services/discovery_engine/query/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,16 @@
)
end
end

context "when a serving config is manually specified" do
let(:query_params) { { q: "garden centres", serving_config: "preview" } }

it "calls the client with the expected parameters" do
expect(client).to have_received(:search).with(
hash_including(serving_config: ServingConfig.new("preview").name),
)
end
end
end
end
end

0 comments on commit 36fbdd9

Please sign in to comment.