From 7f49c09617a67972b587f2716c7b9699ef546c6c Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Thu, 16 Apr 2020 13:47:44 -0600 Subject: [PATCH] move getJoinKey out of constants and into its own file --- .../plugins/maps/common/get_join_key.ts | 8 +++++++ .../maps/common/migrations/join_agg_key.ts | 2 +- x-pack/plugins/maps/common/constants.ts | 21 ------------------ x-pack/plugins/maps/common/get_join_key.ts | 22 +++++++++++++++++++ .../sources/es_term_source/es_term_source.js | 8 ++----- 5 files changed, 33 insertions(+), 28 deletions(-) create mode 100644 x-pack/legacy/plugins/maps/common/get_join_key.ts create mode 100644 x-pack/plugins/maps/common/get_join_key.ts diff --git a/x-pack/legacy/plugins/maps/common/get_join_key.ts b/x-pack/legacy/plugins/maps/common/get_join_key.ts new file mode 100644 index 0000000000000..004f12ca08d2e --- /dev/null +++ b/x-pack/legacy/plugins/maps/common/get_join_key.ts @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +// eslint-disable-next-line @kbn/eslint/no-restricted-paths +export * from '../../../../plugins/maps/common/get_join_key'; diff --git a/x-pack/legacy/plugins/maps/common/migrations/join_agg_key.ts b/x-pack/legacy/plugins/maps/common/migrations/join_agg_key.ts index 4b8f193c9a15d..29661aedb550c 100644 --- a/x-pack/legacy/plugins/maps/common/migrations/join_agg_key.ts +++ b/x-pack/legacy/plugins/maps/common/migrations/join_agg_key.ts @@ -9,11 +9,11 @@ import { AGG_DELIMITER, AGG_TYPE, FIELD_ORIGIN, - getJoinAggKey, JOIN_FIELD_NAME_PREFIX, LAYER_TYPE, VECTOR_STYLES, } from '../constants'; +import { getJoinAggKey } from '../get_join_key'; import { AggDescriptor, JoinDescriptor, diff --git a/x-pack/plugins/maps/common/constants.ts b/x-pack/plugins/maps/common/constants.ts index 0f710432ad529..160f9d8dbc83f 100644 --- a/x-pack/plugins/maps/common/constants.ts +++ b/x-pack/plugins/maps/common/constants.ts @@ -1,9 +1,3 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License; @@ -75,21 +69,6 @@ export enum FIELD_ORIGIN { } export const JOIN_FIELD_NAME_PREFIX = '__kbnjoin__'; -// function in common since its needed by migration -export function getJoinAggKey({ - aggType, - aggFieldName, - rightSourceId, -}: { - aggType: AGG_TYPE; - aggFieldName?: string; - rightSourceId: string; -}) { - const metricKey = - aggType !== AGG_TYPE.COUNT ? `${aggType}${AGG_DELIMITER}${aggFieldName}` : aggType; - return `${JOIN_FIELD_NAME_PREFIX}${metricKey}__${rightSourceId}`; -} - export const SOURCE_DATA_ID_ORIGIN = 'source'; export const META_ID_ORIGIN_SUFFIX = 'meta'; export const SOURCE_META_ID_ORIGIN = `${SOURCE_DATA_ID_ORIGIN}_${META_ID_ORIGIN_SUFFIX}`; diff --git a/x-pack/plugins/maps/common/get_join_key.ts b/x-pack/plugins/maps/common/get_join_key.ts new file mode 100644 index 0000000000000..f1ee95126b9a9 --- /dev/null +++ b/x-pack/plugins/maps/common/get_join_key.ts @@ -0,0 +1,22 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { AGG_DELIMITER, AGG_TYPE, JOIN_FIELD_NAME_PREFIX } from './constants'; + +// function in common since its needed by migration +export function getJoinAggKey({ + aggType, + aggFieldName, + rightSourceId, +}: { + aggType: AGG_TYPE; + aggFieldName?: string; + rightSourceId: string; +}) { + const metricKey = + aggType !== AGG_TYPE.COUNT ? `${aggType}${AGG_DELIMITER}${aggFieldName}` : aggType; + return `${JOIN_FIELD_NAME_PREFIX}${metricKey}__${rightSourceId}`; +} diff --git a/x-pack/plugins/maps/public/layers/sources/es_term_source/es_term_source.js b/x-pack/plugins/maps/public/layers/sources/es_term_source/es_term_source.js index 4f43c93f33f55..cb07bb0e7d2ed 100644 --- a/x-pack/plugins/maps/public/layers/sources/es_term_source/es_term_source.js +++ b/x-pack/plugins/maps/public/layers/sources/es_term_source/es_term_source.js @@ -7,12 +7,8 @@ import _ from 'lodash'; import { i18n } from '@kbn/i18n'; -import { - AGG_TYPE, - DEFAULT_MAX_BUCKETS_LIMIT, - FIELD_ORIGIN, - getJoinAggKey, -} from '../../../../common/constants'; +import { AGG_TYPE, DEFAULT_MAX_BUCKETS_LIMIT, FIELD_ORIGIN } from '../../../../common/constants'; +import { getJoinAggKey } from '../../../../common/get_join_key'; import { ESDocField } from '../../fields/es_doc_field'; import { AbstractESAggSource } from '../es_agg_source'; import { getField, addFieldToDSL, extractPropertiesFromBucket } from '../../util/es_agg_utils';