Skip to content

Commit

Permalink
move getJoinKey out of constants and into its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Apr 16, 2020
1 parent 3c6c15d commit 7f49c09
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 28 deletions.
8 changes: 8 additions & 0 deletions x-pack/legacy/plugins/maps/common/get_join_key.ts
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
21 changes: 0 additions & 21 deletions x-pack/plugins/maps/common/constants.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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}`;
Expand Down
22 changes: 22 additions & 0 deletions x-pack/plugins/maps/common/get_join_key.ts
Original file line number Diff line number Diff line change
@@ -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}`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 7f49c09

Please sign in to comment.