From b343a2862d78f22b3b0ea3ccbe2fd084ed9a3d69 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Tue, 14 Jul 2020 13:11:58 +0100 Subject: [PATCH] fixing merge conflicts --- .../services/new_job_capabilities_service.ts | 2 +- .../models/data_visualizer/data_visualizer.ts | 19 ++++++++++--------- .../ml/server/routes/data_visualizer.ts | 2 +- .../server/routes/api/field_histograms.ts | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/x-pack/plugins/ml/public/application/services/new_job_capabilities_service.ts b/x-pack/plugins/ml/public/application/services/new_job_capabilities_service.ts index bc65ebe7a5fac..e2313de5c88b0 100644 --- a/x-pack/plugins/ml/public/application/services/new_job_capabilities_service.ts +++ b/x-pack/plugins/ml/public/application/services/new_job_capabilities_service.ts @@ -20,7 +20,7 @@ import { import { ml } from './ml_api_service'; import { getIndexPatternAndSavedSearch } from '../util/index_utils'; -// called in the angular routing resolve block to initialize the +// called in the routing resolve block to initialize the // newJobCapsService with the currently selected index pattern export function loadNewJobCapabilities( indexPatternId: string, diff --git a/x-pack/plugins/ml/server/models/data_visualizer/data_visualizer.ts b/x-pack/plugins/ml/server/models/data_visualizer/data_visualizer.ts index 2a2d1da529ed0..7f19f32373e07 100644 --- a/x-pack/plugins/ml/server/models/data_visualizer/data_visualizer.ts +++ b/x-pack/plugins/ml/server/models/data_visualizer/data_visualizer.ts @@ -5,7 +5,6 @@ */ import { ILegacyScopedClusterClient } from 'kibana/server'; -import { LegacyAPICaller } from 'kibana/server'; import _ from 'lodash'; import { KBN_FIELD_TYPES } from '../../../../../../src/plugins/data/server'; import { ML_JOB_FIELD_TYPES } from '../../../common/constants/field_types'; @@ -181,7 +180,7 @@ type BatchStats = | FieldExamples; const getAggIntervals = async ( - callAsCurrentUser: LegacyAPICaller, + { callAsCurrentUser }: ILegacyScopedClusterClient, indexPatternTitle: string, query: any, fields: HistogramField[], @@ -239,14 +238,15 @@ const getAggIntervals = async ( // export for re-use by transforms plugin export const getHistogramsForFields = async ( - callAsCurrentUser: LegacyAPICaller, + mlClusterClient: ILegacyScopedClusterClient, indexPatternTitle: string, query: any, fields: HistogramField[], samplerShardSize: number ) => { + const { callAsCurrentUser } = mlClusterClient; const aggIntervals = await getAggIntervals( - callAsCurrentUser, + mlClusterClient, indexPatternTitle, query, fields, @@ -349,11 +349,12 @@ export const getHistogramsForFields = async ( }; export class DataVisualizer { - callAsCurrentUser: LegacyAPICaller; - - constructor(callAsCurrentUser: LegacyAPICaller) { - this.callAsCurrentUser = callAsCurrentUser; + private _mlClusterClient: ILegacyScopedClusterClient; + private _callAsCurrentUser: ILegacyScopedClusterClient['callAsCurrentUser']; + constructor(mlClusterClient: ILegacyScopedClusterClient) { + this._callAsCurrentUser = mlClusterClient.callAsCurrentUser; + this._mlClusterClient = mlClusterClient; } // Obtains overall stats on the fields in the supplied index pattern, returning an object @@ -449,7 +450,7 @@ export class DataVisualizer { samplerShardSize: number ): Promise { return await getHistogramsForFields( - this.callAsCurrentUser, + this._mlClusterClient, indexPatternTitle, query, fields, diff --git a/x-pack/plugins/ml/server/routes/data_visualizer.ts b/x-pack/plugins/ml/server/routes/data_visualizer.ts index 3c97ee8f77f9c..818e981835ced 100644 --- a/x-pack/plugins/ml/server/routes/data_visualizer.ts +++ b/x-pack/plugins/ml/server/routes/data_visualizer.ts @@ -73,7 +73,7 @@ function getHistogramsForFields( fields: HistogramField[], samplerShardSize: number ) { - const dv = new DataVisualizer(context.ml!.mlClient.callAsCurrentUser); + const dv = new DataVisualizer(context.ml!.mlClient); return dv.getHistogramsForFields(indexPatternTitle, query, fields, samplerShardSize); } diff --git a/x-pack/plugins/transform/server/routes/api/field_histograms.ts b/x-pack/plugins/transform/server/routes/api/field_histograms.ts index d602e49338846..f2fd81368ec17 100644 --- a/x-pack/plugins/transform/server/routes/api/field_histograms.ts +++ b/x-pack/plugins/transform/server/routes/api/field_histograms.ts @@ -34,7 +34,7 @@ export function registerFieldHistogramsRoutes({ router, license }: RouteDependen try { const resp = await getHistogramsForFields( - ctx.transform!.dataClient.callAsCurrentUser, + ctx.transform!.dataClient, indexPatternTitle, query, fields,