Skip to content

Commit

Permalink
Improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal committed Nov 30, 2020
1 parent e0b4d42 commit 3b8b564
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,12 @@ export class IndexPatternsService {
*/
getFieldsForWildcard = async (options: GetFieldsOptions) => {
const metaFields = await this.config.get(UI_SETTINGS.META_FIELDS);
const result = this.apiClient.getFieldsForWildcard({
return this.apiClient.getFieldsForWildcard({
pattern: options.pattern,
metaFields,
type: options.type,
rollupIndex: options.rollupIndex,
});
return result;
};

/**
Expand Down Expand Up @@ -268,22 +267,21 @@ export class IndexPatternsService {
options: GetFieldsOptions,
fieldAttrs: FieldAttrs = {}
) => {
// eslint-disable-next-line no-console
console.log('refreshFieldSpecMap start');
const scriptdFields = Object.values(fields).filter((field) => field.scripted);
try {
const newFields = (await this.getFieldsForWildcard(options)) as FieldSpec[];
return this.fieldArrayToMap([...newFields, ...scriptdFields], fieldAttrs);
} catch (err) {
// eslint-disable-next-line no-console
console.log('refreshFieldSpecMap ERROR');
if (err instanceof IndexPatternMissingIndices) {
this.onNotification({ title: (err as any).message, color: 'danger', iconType: 'alert' });
return {};
}
const msg = i18n.translate('data.indexPatterns.fetchFieldErrorTitle', {
defaultMessage: 'Error fetching fields for index pattern {title} (ID: {id})',
values: { id, title },

this.onError(err, {
title: i18n.translate('data.indexPatterns.fetchFieldErrorTitle', {
defaultMessage: 'Error fetching fields for index pattern {title} (ID: {id})',
values: { id, title },
}),
});
throw err;
}
Expand Down Expand Up @@ -383,8 +381,6 @@ export class IndexPatternsService {
iconType: 'alert',
});
} else {
// eslint-disable-next-line no-console
console.error('fields fetching not possible');
this.onError(err, {
title: i18n.translate('data.indexPatterns.fetchFieldErrorTitle', {
defaultMessage: 'Error fetching fields for index pattern {title} (ID: {id})',
Expand Down Expand Up @@ -512,8 +508,6 @@ export class IndexPatternsService {
.then((resp) => {
indexPattern.id = resp.id;
indexPattern.version = resp.version;
// eslint-disable-next-line no-console
console.error('index pattern saved successfully');
})
.catch(async (err) => {
if (err?.res?.status === 409 && saveAttempts++ < MAX_ATTEMPTS_TO_RESOLVE_CONFLICTS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ export class IndexPatternsApiClient implements IIndexPatternsApiClient {
query,
})
.catch((resp: any) => {
// eslint-disable-next-line no-console
console.error('IndexPatternsApiClient ERROR');
// eslint-disable-next-line no-console
console.error('IndexPatternsApiClient ERROR DEBUG', JSON.stringify(resp));

if (resp.body.statusCode === 404 && resp.body.attributes?.code === 'no_matching_indices') {
throw new IndexPatternMissingIndices(resp.body.message);
}
Expand Down
2 changes: 0 additions & 2 deletions test/functional/apps/discover/_date_nanos.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ export default function ({ getService, getPageObjects }) {
const fromTime = 'Sep 22, 2019 @ 20:31:44.000';
const toTime = 'Sep 23, 2019 @ 03:31:44.000';

// Failing: See https://github.com/elastic/kibana/issues/82035

describe('date_nanos', function () {
before(async function () {
await esArchiver.loadIfNeeded('date_nanos');
Expand Down

0 comments on commit 3b8b564

Please sign in to comment.