Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasolson committed Nov 25, 2019
1 parent 0dcc9c9 commit 2d1da99
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ export class SearchEmbeddable extends Embeddable<SearchInput, SearchOutput>
return getTime(indexPattern, this.input.timeRange);
});

this.filtersSearchSource = searchSource.create()!;
this.filtersSearchSource!.setParent(timeRangeSearchSource);
this.filtersSearchSource = searchSource.create();
this.filtersSearchSource.setParent(timeRangeSearchSource);

searchSource.setParent(this.filtersSearchSource);

Expand Down
3 changes: 1 addition & 2 deletions src/legacy/ui/public/agg_types/buckets/terms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
import chrome from 'ui/chrome';
import { noop } from 'lodash';
import { i18n } from '@kbn/i18n';
import { SearchSource } from '../../courier';
import { SearchSource, getRequestInspectorStats, getResponseInspectorStats } from '../../courier';
import { BucketAggType, BucketAggParam } from './_bucket_agg_type';
import { BUCKET_TYPES } from './bucket_agg_types';
import { AggConfigOptions } from '../agg_config';
import { IBucketAggConfig } from './_bucket_agg_type';
import { getRequestInspectorStats, getResponseInspectorStats } from '../../courier';
import { createFilterTerms } from './create_filter/terms';
import { wrapWithInlineComp } from './inline_comp_wrapper';
import { isStringType, migrateIncludeExcludeFormat } from './migrate_include_exclude_format';
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/ui/public/courier/fetch/call_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function callClient(
const searchStrategy = getSearchStrategyById(searchStrategyId);
const requests = searchStrategyMap[searchStrategyId];

const { searching, abort } = searchStrategy!.search({
const { searching, abort } = searchStrategy.search({
searchRequests: requests,
es,
config,
Expand Down
6 changes: 3 additions & 3 deletions src/legacy/ui/public/courier/fetch/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/

import { SearchError } from '../../courier';
import { KbnError } from '../../../../../plugins/kibana_utils/public';
import { SearchResponse } from '../types';
/**
Expand All @@ -26,9 +27,8 @@ import { SearchResponse } from '../types';
*/
export class RequestFailure extends KbnError {
public resp: SearchResponse;
constructor(err: any, resp?: SearchResponse) {
err = err || false;
super(`Request to Elasticsearch failed: ${JSON.stringify(resp || err.message)}`);
constructor(err: SearchError | null = null, resp?: SearchResponse) {
super(`Request to Elasticsearch failed: ${JSON.stringify(resp || err?.message)}`);

this.resp = resp;
}
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/ui/public/courier/fetch/fetch_soon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export async function fetchSoon(
options: FetchOptions,
{ es, config, esShardTimeout }: FetchHandlers
) {
const msToDelay = config!.get('courier:batchSearches') ? 50 : 0;
const msToDelay = config.get('courier:batchSearches') ? 50 : 0;
return delayedFetch(request, options, { es, config, esShardTimeout }, msToDelay);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { SearchSource } from '../search_source';
import { IndexPattern } from '../../../../core_plugins/data/public/index_patterns';
import { IndexPattern } from '../../../../core_plugins/data/public';

jest.mock('ui/new_platform');

Expand Down
3 changes: 1 addition & 2 deletions src/legacy/ui/public/courier/search_source/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
* under the License.
*/
import { NameList } from 'elasticsearch';
import { esFilters } from '../../../../../plugins/data/public';
import { Query } from '../../../../../plugins/data/common/query';
import { esFilters, Query } from '../../../../../plugins/data/public';
import { IndexPattern } from '../../../../core_plugins/data/public/index_patterns';

export type EsQuerySearchAfter = [string | number, string | number];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class SearchError extends Error {
}
}

export function getSearchErrorType({ message }: { message: string }) {
export function getSearchErrorType({ message }: Pick<SearchError, 'message'>) {
const msg = message.toLowerCase();
if (msg.indexOf('unsupported query') > -1) {
return 'UNSUPPORTED_QUERY';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ export const getSearchStrategyByViability = (indexPattern: IndexPattern) => {
};

export const getSearchStrategyById = (searchStrategyId: string) => {
return [...searchStrategies, noOpSearchStrategy].find(searchStrategy => {
return searchStrategy.id === searchStrategyId;
const searchStrategy = [...searchStrategies, noOpSearchStrategy].find(({ id }) => {
return id === searchStrategyId;
});
return searchStrategy ?? noOpSearchStrategy;
};

export const getSearchStrategyForSearchRequest = (
Expand Down

0 comments on commit 2d1da99

Please sign in to comment.