Skip to content

Commit

Permalink
Update vega_request_handler.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
maryia-lapata committed Apr 23, 2020
1 parent fff77cf commit e323eb1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/plugins/vis_type_vega/public/vega_request_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,22 @@ export function createVegaRequestHandler({
core: { uiSettings },
serviceSettings,
}: VegaVisualizationDependencies) {
let searchCache: SearchCache | undefined;
const { timefilter } = data.query.timefilter;
const timeCache = new TimeCache(timefilter, 3 * 1000);

return ({ timeRange, filters, query, visParams }: VegaRequestHandlerParams) => {
if (!searchCache) {
searchCache = new SearchCache(getData().search.__LEGACY.esClient, {
max: 10,
maxAge: 4 * 1000,
});
}

timeCache.setTimeRange(timeRange);

const esQueryConfigs = esQuery.getEsQueryConfig(uiSettings);
const filtersDsl = esQuery.buildEsQuery(undefined, query, filters, esQueryConfigs);
const searchCache = new SearchCache(getData().search.__LEGACY.esClient, {
max: 10,
maxAge: 4 * 1000,
});
const vp = new VegaParser(visParams.spec, searchCache, timeCache, filtersDsl, serviceSettings);

return vp.parseAsync();
Expand Down

0 comments on commit e323eb1

Please sign in to comment.