Skip to content

Commit

Permalink
re-enable datemath in from/to canvas timelion args
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 committed Dec 4, 2019
1 parent 7ce0a37 commit e5153c0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions x-pack/legacy/plugins/canvas/public/functions/timelion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import { flatten } from 'lodash';
import chrome from 'ui/chrome';
import { npStart } from 'ui/new_platform';
import { ExpressionFunction, DatatableRow } from 'src/plugins/expressions/public';
import { fetch } from '../../common/lib/fetch';
// @ts-ignore untyped local
Expand Down Expand Up @@ -64,8 +65,11 @@ export function timelion(): ExpressionFunction<'timelion', Filter, Arguments, Pr
// workpad, if it exists. Otherwise fall back on the function args.
const timeFilter = context.and.find(and => and.type === 'time');
const range = timeFilter
? { from: timeFilter.from, to: timeFilter.to }
: { from: args.from, to: args.to };
? { min: timeFilter.from, max: timeFilter.to }
: npStart.plugins.data.query.timefilter.timefilter.calculateBounds({
from: args.from,
to: args.to,
});

const body = {
extended: {
Expand All @@ -79,8 +83,8 @@ export function timelion(): ExpressionFunction<'timelion', Filter, Arguments, Pr
},
sheet: [args.query],
time: {
from: range.from,
to: range.to,
from: range.min,
to: range.max,
interval: args.interval,
timezone: args.timezone,
},
Expand Down

0 comments on commit e5153c0

Please sign in to comment.