Skip to content

Commit

Permalink
Merge pull request #155 from alphagov/expose-vertex-attribution-token
Browse files Browse the repository at this point in the history
Expose attribution token from Vertex in API response
  • Loading branch information
csutter authored Dec 15, 2023
2 parents 560bede + bd966d9 commit a587c61
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/result_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
class ResultSet
include ActiveModel::Model

attr_accessor :results, :total, :start
attr_accessor :results, :total, :start, :discovery_engine_attribution_token
end
1 change: 1 addition & 0 deletions app/services/discovery_engine/query/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def result_set
results: response.results.map { Result.from_stored_document(_1.document.struct_data.to_h) },
total: response.total_size,
start: offset,
discovery_engine_attribution_token: response.attribution_token,
)
end

Expand Down
3 changes: 2 additions & 1 deletion spec/services/discovery_engine/query/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
let(:query_params) { { q: "garden centres" } }

let(:search_return_value) { double(response: search_response) }
let(:search_response) { double(total_size: 42, results:) }
let(:search_response) { double(total_size: 42, attribution_token: "footobar", results:) }
let(:results) do
[
double(document: double(struct_data: { title: "Louth Garden Centre" })),
Expand All @@ -54,6 +54,7 @@
end

it "returns a result set with the correct contents" do
expect(result_set.discovery_engine_attribution_token).to eq("footobar")
expect(result_set.start).to eq(0)
expect(result_set.total).to eq(42)
expect(result_set.results.map(&:title)).to eq([
Expand Down

0 comments on commit a587c61

Please sign in to comment.