Skip to content

Commit 4f3492b

Browse files
committed
Address code review feedback
1 parent 58f7bd5 commit 4f3492b

11 files changed

Lines changed: 1115 additions & 319 deletions

app/controllers/search_controller.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def query_timdex(query)
193193
raw = if Feature.enabled?(:geodata)
194194
execute_geospatial_query(query)
195195
else
196-
TimdexBase::Client.query(base_query_for_mode, variables: query)
196+
TimdexBase::Client.query(TimdexSearch::BaseQuery, variables: query)
197197
end
198198

199199
# The response type is a GraphQL::Client::Response, which is not directly serializable, so we
@@ -226,16 +226,10 @@ def execute_geospatial_query(query)
226226
elsif query['geodistance'] == 'true'
227227
TimdexBase::Client.query(TimdexSearch::GeodistanceQuery, variables: query)
228228
else
229-
TimdexBase::Client.query(base_query_for_mode, variables: query)
229+
TimdexBase::Client.query(TimdexSearch::BaseQuery, variables: query)
230230
end
231231
end
232232

233-
def base_query_for_mode
234-
return TimdexSearch::BaseQuery unless Feature.enabled?(:timdex_semantic_search)
235-
236-
TimdexSearch::SemanticBaseQuery
237-
end
238-
239233
def extract_errors(response)
240234
response[:errors]['data'] if response.is_a?(Hash) && response.key?(:errors) && response[:errors].key?('data')
241235
end

app/models/timdex_search.rb

Lines changed: 0 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -3,148 +3,6 @@
33

44
class TimdexSearch < TimdexBase
55
BaseQuery = TimdexBase::Client.parse <<-GRAPHQL
6-
query(
7-
$q: String
8-
$citation: String
9-
$contributors: String
10-
$fundingInformation: String
11-
$identifiers: String
12-
$locations: String
13-
$subjects: String
14-
$title: String
15-
$index: String
16-
$from: String
17-
$booleanType: String
18-
$fulltext: Boolean
19-
$perPage: Int
20-
$accessToFilesFilter: [String!]
21-
$contentTypeFilter: [String!]
22-
$contributorsFilter: [String!]
23-
$formatFilter: [String!]
24-
$languagesFilter: [String!]
25-
$literaryFormFilter: String
26-
$placesFilter: [String!]
27-
$sourceFilter: [String!]
28-
$subjectsFilter: [String!]
29-
) {
30-
search(
31-
searchterm: $q
32-
citation: $citation
33-
contributors: $contributors
34-
fundingInformation: $fundingInformation
35-
identifiers: $identifiers
36-
locations: $locations
37-
subjects: $subjects
38-
title: $title
39-
index: $index
40-
from: $from
41-
booleanType: $booleanType
42-
fulltext: $fulltext
43-
perPage: $perPage
44-
accessToFilesFilter: $accessToFilesFilter
45-
contentTypeFilter: $contentTypeFilter
46-
contributorsFilter: $contributorsFilter
47-
formatFilter: $formatFilter
48-
languagesFilter: $languagesFilter
49-
literaryFormFilter: $literaryFormFilter
50-
placesFilter: $placesFilter
51-
sourceFilter: $sourceFilter
52-
subjectsFilter: $subjectsFilter
53-
) {
54-
hits
55-
records {
56-
timdexRecordId
57-
identifiers {
58-
kind
59-
value
60-
}
61-
title
62-
source
63-
contentType
64-
contributors {
65-
kind
66-
value
67-
}
68-
publicationInformation
69-
dates {
70-
kind
71-
value
72-
range {
73-
gte
74-
lte
75-
}
76-
}
77-
links {
78-
kind
79-
restrictions
80-
text
81-
url
82-
}
83-
notes {
84-
kind
85-
value
86-
}
87-
highlight {
88-
matchedField
89-
matchedPhrases
90-
}
91-
provider
92-
rights {
93-
kind
94-
description
95-
uri
96-
}
97-
sourceLink
98-
summary
99-
subjects {
100-
kind
101-
value
102-
}
103-
citation
104-
}
105-
aggregations {
106-
accessToFiles {
107-
key
108-
docCount
109-
}
110-
contentType {
111-
key
112-
docCount
113-
}
114-
contributors {
115-
key
116-
docCount
117-
}
118-
format {
119-
key
120-
docCount
121-
}
122-
languages {
123-
key
124-
docCount
125-
}
126-
literaryForm {
127-
key
128-
docCount
129-
}
130-
places {
131-
key
132-
docCount
133-
}
134-
source {
135-
key
136-
docCount
137-
}
138-
subjects {
139-
key
140-
docCount
141-
}
142-
}
143-
}
144-
}
145-
GRAPHQL
146-
147-
SemanticBaseQuery = TimdexBase::Client.parse <<-GRAPHQL
1486
query(
1497
$q: String
1508
$citation: String

test/controllers/search_controller_test.rb

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,26 +1220,4 @@ def source_filter_count(controller)
12201220
# Should not be redirected to Turnstile (doesn't hit SearchController)
12211221
assert_response :success
12221222
end
1223-
1224-
test 'uses BaseQuery when semantic search feature is disabled' do
1225-
# When the feature flag is not enabled, base_query_for_mode returns BaseQuery (default tab is 'all')
1226-
mock_primo_search_all_tab
1227-
mock_timdex_search_all_tab
1228-
1229-
get '/results?q=test'
1230-
1231-
assert_response :success
1232-
end
1233-
1234-
test 'uses SemanticBaseQuery when semantic search feature is enabled' do
1235-
# When the feature flag is enabled, base_query_for_mode returns SemanticBaseQuery (default tab is 'all')
1236-
ClimateControl.modify FEATURE_TIMDEX_SEMANTIC_SEARCH: 'true' do
1237-
mock_primo_search_all_tab
1238-
mock_timdex_search_all_tab
1239-
1240-
get '/results?q=test'
1241-
1242-
assert_response :success
1243-
end
1244-
end
12451223
end

test/vcr_cassettes/data.yml

Lines changed: 20 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/vcr_cassettes/data_from_ridiculous_start.yml

Lines changed: 17 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/vcr_cassettes/data_page_2.yml

Lines changed: 20 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/vcr_cassettes/timdex_empty_search.yml

Lines changed: 501 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/vcr_cassettes/timdex_error.yml

Lines changed: 37 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/vcr_cassettes/timdex_no_results.yml

Lines changed: 16 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/vcr_cassettes/timdex_null_search.yml

Lines changed: 502 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)