Refactor: improvements to PanelQueryRunner (#16678)

merged DataQueryOptions + DataRequestInfo info: DataQueryRequest
This commit is contained in:
Ryan McKinley
2019-04-18 21:56:27 -07:00
committed by GitHub
parent 5f474c6328
commit 4e54509dde
14 changed files with 87 additions and 45 deletions

View File

@ -1,15 +1,15 @@
import { DataQueryOptions, DataQuery } from '@grafana/ui';
import { DataQueryRequest, DataQuery } from '@grafana/ui';
import moment from 'moment';
export function getQueryOptions<TQuery extends DataQuery>(
options: Partial<DataQueryOptions<TQuery>>
): DataQueryOptions<TQuery> {
options: Partial<DataQueryRequest<TQuery>>
): DataQueryRequest<TQuery> {
const raw = { from: 'now', to: 'now-1h' };
const range = { from: moment(), to: moment(), raw: raw };
const defaults: DataQueryOptions<TQuery> = {
const defaults: DataQueryRequest<TQuery> = {
requestId: 'TEST',
range: range,
rangeRaw: raw,
targets: [],
scopedVars: {},
timezone: 'browser',
@ -18,6 +18,7 @@ export function getQueryOptions<TQuery extends DataQuery>(
interval: '60s',
intervalMs: 60000,
maxDataPoints: 500,
startTime: 0,
};
Object.assign(defaults, options);