Skip to content

Commit 8c3324f

Browse files
committed
fix PR comments
1 parent 1fcf01e commit 8c3324f

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

src/plugins/data/server/autocomplete/value_suggestions_route.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { get, map } from 'lodash';
2121
import { schema } from '@kbn/config-schema';
2222
import { APICaller, IRouter, KibanaRequest } from 'kibana/server';
2323

24-
import { IFieldType, indexPatternsUtils, esFilters } from '../index';
24+
import { IFieldType, indexPatterns, esFilters } from '../index';
2525

2626
export function registerValueSuggestionsRoute(
2727
router: IRouter,
@@ -57,12 +57,12 @@ export function registerValueSuggestionsRoute(
5757
terminate_after: await uiSettings.get<number>('kibana.autocompleteTerminateAfter'),
5858
};
5959

60-
const indexPattern = await indexPatternsUtils.findIndexPatternById(
60+
const indexPattern = await indexPatterns.findIndexPatternById(
6161
context.core.savedObjects.client,
6262
index
6363
);
6464

65-
const field = indexPatternsUtils.getFieldByName(fieldName, indexPattern);
65+
const field = indexPattern && indexPatterns.getFieldByName(fieldName, indexPattern);
6666
const body = await getBody(autocompleteSearchOptions, field || fieldName, query, boolFilter);
6767

6868
try {

src/plugins/data/server/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export {
5757
IndexPatternsFetcher,
5858
FieldDescriptor,
5959
shouldReadFieldFromDocValues,
60-
indexPatternsUtils,
60+
indexPatterns,
6161
} from './index_patterns';
6262
export * from './search';
6363
export {

src/plugins/data/server/index_patterns/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
import * as indexPatternsUtils from './utils';
19+
import * as indexPatterns from './utils';
2020

2121
export { IndexPatternsFetcher, FieldDescriptor, shouldReadFieldFromDocValues } from './fetcher';
2222
export { IndexPatternsService } from './index_patterns_service';
23-
export { indexPatternsUtils };
23+
export { indexPatterns };

src/plugins/data/server/index_patterns/utils.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,12 @@ import { IIndexPattern, IFieldType } from '../../common';
2222

2323
export const getFieldByName = (
2424
fieldName: string,
25-
indexPattern?: IIndexPattern
25+
indexPattern: IIndexPattern
2626
): IFieldType | undefined => {
27-
if (indexPattern) {
28-
const fields: IFieldType[] = indexPattern && JSON.parse(indexPattern.attributes.fields);
29-
const field = fields && fields.find(f => f.name === fieldName);
27+
const fields: IFieldType[] = indexPattern && JSON.parse(indexPattern.attributes.fields);
28+
const field = fields && fields.find(f => f.name === fieldName);
3029

31-
if (field) {
32-
return field;
33-
}
34-
}
30+
return field;
3531
};
3632

3733
export const findIndexPatternById = async (

0 commit comments

Comments
 (0)