Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand All @@ -25,7 +25,7 @@ const rightSource = {
term: 'geo.dest',
};

const leftJoin = new LeftInnerJoin({
const leftJoin = new InnerJoin({
leftField: 'iso2',
right: rightSource
});
Expand Down Expand Up @@ -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
});
Expand Down Expand Up @@ -115,7 +115,7 @@ describe('joinPropertiesToFeature', () => {

it('Should handle falsy values', () => {

const leftJoin = new LeftInnerJoin({
const leftJoin = new InnerJoin({
leftField: 'code',
right: rightSource
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({}) {
Expand All @@ -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() {
Expand Down Expand Up @@ -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
Expand All @@ -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';
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => ({
Expand Down Expand Up @@ -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,
});
Expand All @@ -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,
Expand All @@ -76,7 +76,7 @@ describe('_makeAggConfigs', () => {
describe('no metrics', () => {
let aggConfigs;
beforeAll(() => {
const source = new ESJoinSource({
const source = new ESTermSource({
indexPatternTitle: indexPatternTitle,
term: termFieldName,
});
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions x-pack/legacy/plugins/maps/public/layers/vector_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()));
});
}
}
Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions x-pack/legacy/plugins/maps/public/layers/vector_layer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => ({
Expand Down