Skip to content

Commit

Permalink
simplified the some if statements in executeGDA
Browse files Browse the repository at this point in the history
  • Loading branch information
anguyen-yext2 committed Jun 10, 2024
1 parent 046f178 commit 9554b3e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions src/search-headless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,29 +575,21 @@ export default class SearchHeadless {
let results: VerticalResults[] | undefined;
if (this.state.meta.searchType === SearchTypeEnum.Vertical) {
requestName = 'verticalQuery';

if (!this.state.vertical || !this.state.vertical.appliedQueryFilters
|| !this.state.vertical.queryDurationMillis || !this.state.vertical.results
|| !this.state.vertical.resultsCount || !this.state.vertical.source
|| !this.state.vertical.source || !this.state.vertical.verticalKey ) {
console.error('no results supplied for generative direct answer');
return;
if (this.state.vertical.appliedQueryFilters && this.state.vertical.queryDurationMillis

Check warning on line 578 in src/search-headless.ts

View workflow job for this annotation

GitHub Actions / linting / linting

Trailing spaces not allowed
&& this.state.vertical.results && this.state.vertical.resultsCount

Check warning on line 579 in src/search-headless.ts

View workflow job for this annotation

GitHub Actions / linting / linting

Trailing spaces not allowed
&& this.state.vertical.source && this.state.vertical.verticalKey ) {
results = [{
appliedQueryFilters: this.state.vertical.appliedQueryFilters,
queryDurationMillis: this.state.vertical.queryDurationMillis,
results: this.state.vertical.results,
resultsCount: this.state.vertical.resultsCount,
source: this.state.vertical.source,
verticalKey: this.state.vertical.verticalKey,
}];
}
results = [{
appliedQueryFilters: this.state.vertical.appliedQueryFilters,
queryDurationMillis: this.state.vertical.queryDurationMillis,
results: this.state.vertical.results,
resultsCount: this.state.vertical.resultsCount,
source: this.state.vertical.source,
verticalKey: this.state.vertical.verticalKey,
}];
} else if (this.state.meta.searchType === SearchTypeEnum.Universal) {
} else {
requestName = 'universalQuery';
results = this.state.universal.verticals;
} else {
console.error('The meta.searchType must be set to \'vertical\' or \'universal\' for generativeDirectAnswer. '
+ 'Set the searchType by calling `setVertical()` or `setUniversal()`');
return;
}
if (!results || results.length === 0) {
console.error('no results supplied for generative direct answer');
Expand Down
Binary file removed yext-search-headless-2.6.0-beta.tgz
Binary file not shown.

0 comments on commit 9554b3e

Please sign in to comment.