Skip to content

Commit 42b456a

Browse files
ddimensiaBrandonArp
authored andcommitted
Added ability to set a time override on a per-query basis. (#6)
1 parent 00098c5 commit 42b456a

40 files changed

+1326
-28
lines changed

Gruntfile.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,15 @@ module.exports = function (grunt) {
6161
],
6262
dest: "dist/",
6363
options: {
64+
moduleResolution: "node",
6465
module: "system",
6566
target: "es5",
6667
rootDir: "dist/",
68+
allowSyntheticDefaultImports: true,
6769
keepDirectoryHierarchy: false,
6870
declaration: true,
6971
emitDecoratorMetadata: true,
72+
esModuleInterop: true,
7073
experimentalDecorators: true,
7174
sourceMap: true,
7275
noImplicitAny: false

dist/beans/request/metric_query.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ export declare class MetricQuery {
44
limit: number;
55
aggregators: any[];
66
group_by: any[];
7-
constructor(name: string, tags: any, aggregators: any[], group_by: any[]);
7+
start_absolute: number;
8+
end_absolute: number;
9+
constructor(name: string, tags: any, aggregators: any[], group_by: any[], start_absolute: number, end_absolute: number);
810
}

dist/beans/request/metric_query.js

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/beans/request/metric_query.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/beans/request/metric_query.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ export class MetricQuery {
44
public limit: number = 0;
55
public aggregators: any[];
66
public group_by: any[];
7+
public start_absolute: number;
8+
public end_absolute: number;
79

8-
constructor(name: string, tags: any, aggregators: any[], group_by: any[]) {
10+
constructor(name: string, tags: any, aggregators: any[], group_by: any[], start_absolute: number, end_absolute: number) {
911
this.name = name;
1012
this.tags = tags;
1113
this.aggregators = aggregators;
1214
this.group_by = group_by;
15+
this.start_absolute = start_absolute;
16+
this.end_absolute = end_absolute;
1317
}
1418
}

dist/beans/request/target.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1+
import { Moment } from "moment";
12
import { Aggregator } from "../aggregators/aggregator";
23
import { GroupBy } from "./group_by";
4+
export interface TimeRange {
5+
from: Moment | string;
6+
to: Moment | string;
7+
}
38
export declare class KairosDBTarget {
49
static fromObject(object: any): KairosDBTarget;
10+
static startTime(target: KairosDBTarget): number;
11+
static endTime(target: KairosDBTarget): number;
512
metricName: string;
613
alias: string;
714
tags: {
815
[key: string]: string[];
916
};
1017
groupBy: GroupBy;
1118
aggregators: Aggregator[];
19+
timeRange: TimeRange;
1220
asString(): string;
1321
}

dist/beans/request/target.js

Lines changed: 25 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/beans/request/target.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/beans/request/target.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
import * as dateMath from "app/core/utils/datemath";
2+
import {Moment} from "moment";
13
import {Aggregator} from "../aggregators/aggregator";
24
import * as Aggregators from "../aggregators/aggregators";
35
import {AggregatorParameter} from "../aggregators/parameters/aggregator_parameter";
46
import {GroupBy} from "./group_by";
57

8+
export interface TimeRange {
9+
from: Moment | string;
10+
to: Moment | string;
11+
}
12+
613
export class KairosDBTarget {
714
public static fromObject(object: any): KairosDBTarget {
815
const rval = new KairosDBTarget();
@@ -12,14 +19,36 @@ export class KairosDBTarget {
1219
rval.groupBy = GroupBy.fromObject(object.groupBy);
1320
rval.aggregators = (object.aggregators || []).map(
1421
(val) => Aggregators.fromObject(val));
22+
rval.timeRange = object.timeRange;
1523
return rval;
1624
}
1725

26+
public static startTime(target: KairosDBTarget): number {
27+
if (target.timeRange) {
28+
const startMoment: Moment = dateMath.parse(target.timeRange.from);
29+
if (startMoment) {
30+
return startMoment.unix() * 1000;
31+
}
32+
}
33+
return undefined;
34+
}
35+
36+
public static endTime(target: KairosDBTarget): number {
37+
if (target.timeRange) {
38+
const endMoment: Moment = dateMath.parse(target.timeRange.to);
39+
if (endMoment) {
40+
return endMoment.unix() * 1000;
41+
}
42+
}
43+
return undefined;
44+
}
45+
1846
public metricName: string = undefined;
1947
public alias: string = undefined;
2048
public tags: {[key: string]: string[]} = {};
2149
public groupBy: GroupBy = new GroupBy();
2250
public aggregators: Aggregator[] = [];
51+
public timeRange: TimeRange = undefined;
2352

2453
public asString(): string {
2554
let str = "SELECT ";

dist/core/request/query_builder.js

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)