From 2e5102f114c96454e75be69f79958c30868031b9 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Tue, 6 Aug 2019 13:57:19 +0300 Subject: [PATCH] fix PR comments --- .../core_plugins/vis_type_vega/public/vega_fn.ts | 9 ++++----- .../vis_type_vega/public/vega_request_handler.ts | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/legacy/core_plugins/vis_type_vega/public/vega_fn.ts b/src/legacy/core_plugins/vis_type_vega/public/vega_fn.ts index dd39cfd6d0f1e..6bbeec38039aa 100644 --- a/src/legacy/core_plugins/vis_type_vega/public/vega_fn.ts +++ b/src/legacy/core_plugins/vis_type_vega/public/vega_fn.ts @@ -31,7 +31,7 @@ interface Arguments { spec: string; } -type VisParams = Required; +export type VisParams = Required; interface RenderValue { visData: Context; @@ -63,11 +63,10 @@ export const createVegaFn = ( const vegaRequestHandler = createVegaRequestHandler(dependencies); const response = await vegaRequestHandler({ - timeRange: get(context, 'timeRange', null), - query: get(context, 'query', null), - filters: get(context, 'filters', null), + timeRange: get(context, 'timeRange'), + query: get(context, 'query'), + filters: get(context, 'filters'), visParams: { spec: args.spec }, - forceFetch: true, }); return { diff --git a/src/legacy/core_plugins/vis_type_vega/public/vega_request_handler.ts b/src/legacy/core_plugins/vis_type_vega/public/vega_request_handler.ts index b848d4f075610..58754f6f5d941 100644 --- a/src/legacy/core_plugins/vis_type_vega/public/vega_request_handler.ts +++ b/src/legacy/core_plugins/vis_type_vega/public/vega_request_handler.ts @@ -16,7 +16,10 @@ * specific language governing permissions and limitations * under the License. */ +import { Filter } from '@kbn/es-query'; import { timefilter } from 'ui/timefilter'; +import { TimeRange } from 'ui/timefilter/time_history'; +import { Query } from 'src/legacy/core_plugins/data/public'; // @ts-ignore import { buildEsQuery, getEsQueryConfig } from '@kbn/es-query'; @@ -28,16 +31,24 @@ import { SearchCache } from './data_model/search_cache'; import { TimeCache } from './data_model/time_cache'; import { VegaVisualizationDependencies } from './plugin'; +import { VisParams } from './vega_fn'; + +interface VegaRequestHandlerParams { + query: Query; + filters: Filter; + timeRange: TimeRange; + visParams: VisParams; +} export function createVegaRequestHandler({ - uiSettings, es, + uiSettings, serviceSettings, }: VegaVisualizationDependencies) { const searchCache = new SearchCache(es, { max: 10, maxAge: 4 * 1000 }); const timeCache = new TimeCache(timefilter, 3 * 1000); - return ({ timeRange, filters, query, visParams }: any) => { + return ({ timeRange, filters, query, visParams }: VegaRequestHandlerParams) => { timeCache.setTimeRange(timeRange); const esQueryConfigs = getEsQueryConfig(uiSettings);