Skip to content

Commit

Permalink
fix PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Aug 6, 2019
1 parent 36d226c commit 2e5102f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/legacy/core_plugins/vis_type_vega/public/vega_fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface Arguments {
spec: string;
}

type VisParams = Required<Arguments>;
export type VisParams = Required<Arguments>;

interface RenderValue {
visData: Context;
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
Expand Down

0 comments on commit 2e5102f

Please sign in to comment.