diff --git a/x-pack/legacy/plugins/maps/public/layers/joins/left_inner_join.js b/x-pack/legacy/plugins/maps/public/layers/joins/inner_join.js similarity index 94% rename from x-pack/legacy/plugins/maps/public/layers/joins/left_inner_join.js rename to x-pack/legacy/plugins/maps/public/layers/joins/inner_join.js index 372e23b2f489b3..dac05128e8d292 100644 --- a/x-pack/legacy/plugins/maps/public/layers/joins/left_inner_join.js +++ b/x-pack/legacy/plugins/maps/public/layers/joins/inner_join.js @@ -5,14 +5,14 @@ */ -import { ESJoinSource } from '../sources/es_join_source'; +import { ESTermSource } from '../sources/es_term_source'; import { VectorStyle } from '../styles/vector_style'; -export class LeftInnerJoin { +export class InnerJoin { constructor(joinDescriptor, inspectorAdapters) { this._descriptor = joinDescriptor; - this._rightSource = new ESJoinSource(joinDescriptor.right, inspectorAdapters); + this._rightSource = new ESTermSource(joinDescriptor.right, inspectorAdapters); } destroy() { diff --git a/x-pack/legacy/plugins/maps/public/layers/joins/left_inner_join.test.js b/x-pack/legacy/plugins/maps/public/layers/joins/inner_join.test.js similarity index 95% rename from x-pack/legacy/plugins/maps/public/layers/joins/left_inner_join.test.js rename to x-pack/legacy/plugins/maps/public/layers/joins/inner_join.test.js index f6f9a96390f322..0a5a885739f865 100644 --- a/x-pack/legacy/plugins/maps/public/layers/joins/left_inner_join.test.js +++ b/x-pack/legacy/plugins/maps/public/layers/joins/inner_join.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { LeftInnerJoin } from './left_inner_join'; +import { InnerJoin } from './inner_join'; jest.mock('ui/vis/editors/default/schemas', () => { class MockSchemas {} @@ -25,7 +25,7 @@ const rightSource = { term: 'geo.dest', }; -const leftJoin = new LeftInnerJoin({ +const leftJoin = new InnerJoin({ leftField: 'iso2', right: rightSource }); @@ -73,7 +73,7 @@ describe('joinPropertiesToFeature', () => { it('Should coerce to string before joining', () => { - const leftJoin = new LeftInnerJoin({ + const leftJoin = new InnerJoin({ leftField: 'zipcode', right: rightSource }); @@ -115,7 +115,7 @@ describe('joinPropertiesToFeature', () => { it('Should handle falsy values', () => { - const leftJoin = new LeftInnerJoin({ + const leftJoin = new InnerJoin({ leftField: 'code', right: rightSource }); diff --git a/x-pack/legacy/plugins/maps/public/layers/sources/es_join_source.js b/x-pack/legacy/plugins/maps/public/layers/sources/es_term_source.js similarity index 94% rename from x-pack/legacy/plugins/maps/public/layers/sources/es_join_source.js rename to x-pack/legacy/plugins/maps/public/layers/sources/es_term_source.js index cd2b3151948c2b..ad404d9af1eadf 100644 --- a/x-pack/legacy/plugins/maps/public/layers/sources/es_join_source.js +++ b/x-pack/legacy/plugins/maps/public/layers/sources/es_term_source.js @@ -54,9 +54,9 @@ export function extractPropertiesMap(rawEsData, propertyNames, countPropertyName return propertiesMap; } -export class ESJoinSource extends AbstractESSource { +export class ESTermSource extends AbstractESSource { - static type = 'ES_JOIN_SOURCE'; + static type = 'ES_TERM_SOURCE'; static renderEditor({}) { @@ -65,11 +65,7 @@ export class ESJoinSource extends AbstractESSource { } hasCompleteConfig() { - if (_.has(this._descriptor, 'indexPatternId') && _.has(this._descriptor, 'term')) { - return true; - } - - return false; + return (_.has(this._descriptor, 'indexPatternId') && _.has(this._descriptor, 'term')); } getIndexPatternIds() { @@ -107,7 +103,7 @@ export class ESJoinSource extends AbstractESSource { searchSource.setField('aggs', aggConfigs.toDsl()); const requestName = `${this._descriptor.indexPatternTitle}.${this._descriptor.term}`; - const requestDesc = this.getJoinDescription(leftSourceName, leftFieldName); + const requestDesc = this._getRequestDescription(leftSourceName, leftFieldName); const rawEsData = await this._runEsQuery(requestName, searchSource, requestDesc); const metricPropertyNames = configStates @@ -130,7 +126,7 @@ export class ESJoinSource extends AbstractESSource { return false; } - getJoinDescription(leftSourceName, leftFieldName) { + _getRequestDescription(leftSourceName, leftFieldName) { const metrics = this._getValidMetrics().map(metric => { return metric.type !== 'count' ? `${metric.type} ${metric.field}` : 'count'; }); diff --git a/x-pack/legacy/plugins/maps/public/layers/sources/es_join_source.test.js b/x-pack/legacy/plugins/maps/public/layers/sources/es_term_source.test.js similarity index 96% rename from x-pack/legacy/plugins/maps/public/layers/sources/es_join_source.test.js rename to x-pack/legacy/plugins/maps/public/layers/sources/es_term_source.test.js index 7e12a3880dc503..65bfd993c871a8 100644 --- a/x-pack/legacy/plugins/maps/public/layers/sources/es_join_source.test.js +++ b/x-pack/legacy/plugins/maps/public/layers/sources/es_term_source.test.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { ESJoinSource, extractPropertiesMap } from './es_join_source'; +import { ESTermSource, extractPropertiesMap } from './es_term_source'; jest.mock('../vector_layer', () => {}); jest.mock('ui/vis/editors/default/schemas', () => ({ @@ -37,7 +37,7 @@ const metricExamples = [ describe('getMetricFields', () => { it('should add default "count" metric when no metrics are provided', () => { - const source = new ESJoinSource({ + const source = new ESTermSource({ indexPatternTitle: indexPatternTitle, term: termFieldName, }); @@ -51,7 +51,7 @@ describe('getMetricFields', () => { }); it('should remove incomplete metric configurations', () => { - const source = new ESJoinSource({ + const source = new ESTermSource({ indexPatternTitle: indexPatternTitle, term: termFieldName, metrics: metricExamples, @@ -76,7 +76,7 @@ describe('_makeAggConfigs', () => { describe('no metrics', () => { let aggConfigs; beforeAll(() => { - const source = new ESJoinSource({ + const source = new ESTermSource({ indexPatternTitle: indexPatternTitle, term: termFieldName, }); @@ -112,7 +112,7 @@ describe('_makeAggConfigs', () => { describe('metrics', () => { let aggConfigs; beforeAll(() => { - const source = new ESJoinSource({ + const source = new ESTermSource({ indexPatternTitle: indexPatternTitle, term: 'myTermField', metrics: metricExamples diff --git a/x-pack/legacy/plugins/maps/public/layers/vector_layer.js b/x-pack/legacy/plugins/maps/public/layers/vector_layer.js index d395f8ead1baaa..829ce8ea599f81 100644 --- a/x-pack/legacy/plugins/maps/public/layers/vector_layer.js +++ b/x-pack/legacy/plugins/maps/public/layers/vector_layer.js @@ -8,7 +8,7 @@ import turf from 'turf'; import React from 'react'; import { AbstractLayer } from './layer'; import { VectorStyle } from './styles/vector_style'; -import { LeftInnerJoin } from './joins/left_inner_join'; +import { InnerJoin } from './joins/inner_join'; import { GEO_JSON_TYPE, FEATURE_ID_PROPERTY_NAME, @@ -88,7 +88,7 @@ export class VectorLayer extends AbstractLayer { this._joins = []; if (options.layerDescriptor.joins) { options.layerDescriptor.joins.forEach((joinDescriptor) => { - this._joins.push(new LeftInnerJoin(joinDescriptor, this._source.getInspectorAdapters())); + this._joins.push(new InnerJoin(joinDescriptor, this._source.getInspectorAdapters())); }); } } @@ -430,9 +430,9 @@ export class VectorLayer extends AbstractLayer { let isFeatureVisible = true; for (let j = 0; j < joinStates.length; j++) { const joinState = joinStates[j]; - const leftInnerJoin = joinState.join; - const rightMetricFields = leftInnerJoin.getRightMetricFields(); - const canJoinOnCurrent = leftInnerJoin.joinPropertiesToFeature(feature, joinState.propertiesMap, rightMetricFields); + const InnerJoin = joinState.join; + const rightMetricFields = InnerJoin.getRightMetricFields(); + const canJoinOnCurrent = InnerJoin.joinPropertiesToFeature(feature, joinState.propertiesMap, rightMetricFields); isFeatureVisible = isFeatureVisible && canJoinOnCurrent; } diff --git a/x-pack/legacy/plugins/maps/public/layers/vector_layer.test.js b/x-pack/legacy/plugins/maps/public/layers/vector_layer.test.js index 85937c2783cce6..0a07582c57856d 100644 --- a/x-pack/legacy/plugins/maps/public/layers/vector_layer.test.js +++ b/x-pack/legacy/plugins/maps/public/layers/vector_layer.test.js @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -jest.mock('./joins/left_inner_join', () => ({ - LeftInnerJoin: Object +jest.mock('./joins/inner_join', () => ({ + InnerJoin: Object })); jest.mock('./tooltips/join_tooltip_property', () => ({