-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(swift): QuerySuggestionsConfigurationResponse appID casing (#2712)
Co-authored-by: Pierre Millot <pierre.millot@algolia.com>
- Loading branch information
Showing
9 changed files
with
141 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,43 @@ | ||
[ | ||
{ | ||
"testName": "Retrieve QS config e2e", | ||
"parameters": { | ||
"indexName": "theIndexName" | ||
"indexName": "cts_e2e_browse_query_suggestions" | ||
}, | ||
"request": { | ||
"path": "/1/configs/theIndexName", | ||
"path": "/1/configs/cts_e2e_browse_query_suggestions", | ||
"method": "GET" | ||
}, | ||
"response": { | ||
"statusCode": 200, | ||
"body": { | ||
"allowSpecialCharacters": true, | ||
"enablePersonalization": false, | ||
"exclude": [ | ||
"^cocaines$" | ||
], | ||
"indexName": "cts_e2e_browse_query_suggestions", | ||
"languages": [], | ||
"sourceIndices": [ | ||
{ | ||
"facets": [ | ||
{ | ||
"amount": 1, | ||
"attribute": "title" | ||
} | ||
], | ||
"generate": [ | ||
[ | ||
"year" | ||
] | ||
], | ||
"indexName": "cts_e2e_browse", | ||
"minHits": 5, | ||
"minLetters": 4, | ||
"replicas": false | ||
} | ||
] | ||
} | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,25 @@ | ||
export function union( | ||
expected: Record<string, any>, | ||
received: Record<string, any> | ||
): Record<string, any> { | ||
const res = {}; | ||
|
||
if (!expected) { | ||
return expected; | ||
} | ||
export function union(expected: any, received: any): any { | ||
if (Array.isArray(expected)) { | ||
if (Array.isArray(received)) { | ||
const res = new Array(expected.length); | ||
for (const [i, v] of expected.entries()) { | ||
res[i] = union(v, received[i]); | ||
} | ||
|
||
if (typeof expected !== 'object' && !Array.isArray(expected)) { | ||
return expected; | ||
return res; | ||
} | ||
return received; | ||
} | ||
|
||
for (const [key, value] of Object.entries(expected)) { | ||
if (key in received) { | ||
if (Array.isArray(value)) { | ||
if (res[key] === undefined) { | ||
res[key] = []; | ||
} | ||
|
||
for (const [i, v] of value.entries()) { | ||
res[key].push(union(v, received[key][i])); | ||
} | ||
} else if (typeof value === 'object') { | ||
if (typeof expected === 'object' && expected !== null) { | ||
const res = {}; | ||
for (const [key, value] of Object.entries(expected)) { | ||
if (key in received) { | ||
res[key] = union(value, received[key]); | ||
} else { | ||
res[key] = received[key]; | ||
} | ||
} | ||
|
||
return res; | ||
} | ||
|
||
return res; | ||
return received; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,16 @@ | ||
class Helpers: | ||
def union(self, expected: dict, received: dict) -> dict: | ||
def union(self, expected, received): | ||
""" | ||
creates a new dict based on the keys of 'expected' that are also in 'received' | ||
creates a new result based on the keys of 'expected' that are also in 'received' | ||
""" | ||
_res = {} | ||
|
||
if not isinstance(expected, dict) or not isinstance(received, dict): | ||
return received | ||
|
||
for k, v in expected.items(): | ||
if k in received: | ||
if isinstance(v, dict): | ||
_res[k] = self.union(v, received[k]) | ||
elif isinstance(v, list): | ||
if _res.get(k) is None: | ||
_res[k] = [] | ||
|
||
for _iv, _v in enumerate(v): | ||
_res[k].append(self.union(_v, received[k][_iv])) | ||
else: | ||
_res[k] = received[k] | ||
|
||
return _res | ||
if isinstance(expected, list): | ||
_res = [] | ||
for _iv, _v in enumerate(expected): | ||
_res.append(self.union(_v, received[_iv])) | ||
return _res | ||
if isinstance(expected, dict): | ||
_res = {} | ||
for k, v in expected.items(): | ||
_res[k] = self.union(v, received[k]) | ||
return _res | ||
return received |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,20 @@ | ||
def union(expected, received) | ||
res = {} | ||
|
||
if !expected.is_a?(Array) and !expected.is_a?(Hash) | ||
return expected | ||
end | ||
|
||
if received.nil? | ||
return nil | ||
end | ||
|
||
expected.each do |key, value| | ||
if received.key?(key) | ||
if value.is_a?(Array) | ||
res[key] = [] if res[key].nil? | ||
case expected | ||
when Array | ||
res = [] | ||
expected.each_with_index do |v, i| | ||
res.push(union(v, received[i])) | ||
end | ||
|
||
value.each_with_index do |v, i| | ||
res[key].push(union(v, received[key][i])) | ||
end | ||
elsif value.is_a?(Hash) | ||
res[key] = union(value, received[key]) | ||
else | ||
res[key] = received[key] | ||
end | ||
return res | ||
when Hash | ||
res = {} | ||
expected.each do |key, value| | ||
res[key] = union(value, received[key]) | ||
end | ||
end | ||
|
||
res | ||
return res | ||
else | ||
return received | ||
end | ||
end |
Oops, something went wrong.