Skip to content

Commit

Permalink
Merge pull request #5 from AquaQAnalytics/timezonefix
Browse files Browse the repository at this point in the history
Fixed c.js time offset in temporal_range
  • Loading branch information
DGaquaq authored Mar 30, 2020
2 parents f1c15dd + be67ac8 commit 8481a23
Show file tree
Hide file tree
Showing 20 changed files with 113 additions and 90 deletions.
3 changes: 3 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ however there are known bugs with lesser used browsers:

We recommend using the latest version of either Google Chrome or Mozilla Firefox.

#### Time Zones:
Grafana time ranges have support for UTC time, local browser time or Grafana server time. As kdb+ does not have native time-zone support **all timestamps/datetimes in kdb+ are interpreted as UTC+0**. We recommend dashboards are set to UTC time to avoid confusion.

#### Grafana Service:
On **Windows** grafana will by default install itself as a service. To view running services, run:

Expand Down
132 changes: 65 additions & 67 deletions dist/README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/datasource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export declare class KDBDatasource {
interpolateVariable: (value: any, variable: any) => any;
private buildKdbRequest(target);
private buildTemporalField(queryDetails);
private buildKdbTimestamp(date);
private buildTemporalRange(range);
private buildWhereParams(queryWhereList);
private buildColumnParams(target);
Expand Down
7 changes: 5 additions & 2 deletions dist/datasource.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/datasource.js.map

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions dist/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { QueryParam } from "./model/query-param";
import { QueryDictionary } from "./model/queryDictionary";
import { ConflationParams } from "./model/conflationParams";
import { graphFunction } from './model/kdb-request-config';
import { tabFunction,defaultTimeout } from './model/kdb-request-config';
import { tabFunction,defaultTimeout,kdbEpoch } from './model/kdb-request-config';
export class KDBDatasource {
//This is declaring the types of each member
id: any;
Expand Down Expand Up @@ -146,11 +146,15 @@ export class KDBDatasource {
};
};

private buildKdbTimestamp(date : Date) {
return 1000000 * (date.valueOf() - kdbEpoch);
}

private buildTemporalRange(range) {
let temporalRange: Date[] = [];
let temporalRange: number[] = [];
if (range) {
temporalRange.push(new Date(range.from._d));
temporalRange.push(new Date(range.to._d));
temporalRange.push(this.buildKdbTimestamp(range.from._d));
temporalRange.push(this.buildKdbTimestamp(range.to._d));
}
return temporalRange;
};
Expand Down
1 change: 1 addition & 0 deletions dist/model/kdb-request-config.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export declare const defaultRowCountLimit: number;
export declare var defaultTimeout: number;
export declare const kdbEpoch: number;
export declare const graphFunction: string;
export declare const tabFunction: string;
export declare const argCounter: string;
5 changes: 4 additions & 1 deletion dist/model/kdb-request-config.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/model/kdb-request-config.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dist/model/kdb-request-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//The default for the number
export const defaultRowCountLimit : number = 10000;
export var defaultTimeout : number = 5000;
export const kdbEpoch : number = 946684800000

//Graph response type
export const graphFunction: string = '{@[x;y;{`payload`error`success!(();"Error! - ",x;0b)}]}{[dict] \n ' +
Expand Down Expand Up @@ -73,6 +74,7 @@ export const graphFunction: string = '{@[x;y;{`payload`error`success!(();"Error
' (dict[`queryParam;`maxRowCount];dict[`queryId]); \n ' +
' \n ' +
' d:dict`queryParam; \n ' +
' d[`temporal_range]:`timestamp$d[`temporal_range]; \n ' +
' qt:d[`query;`type]; \n ' +
' funcparts:enlist[`CAST]!enlist("CAST";"AS";"MIXED LIST"); \n ' +
' gr:enlist[`CAST]!enlist("CAST";"AS";"MIXED LIST"); \n ' +
Expand Down Expand Up @@ -248,6 +250,7 @@ export const tabFunction: string = '{@[x;y;{`payload`error`success!(();"Error! -
' (dict[`queryParam;`maxRowCount];dict[`queryId]); \n ' +
' \n ' +
' d:dict`queryParam; \n ' +
' d[`temporal_range]:`timestamp$d[`temporal_range]; \n ' +
' qt:d[`query;`type]; \n ' +
' funcparts:enlist[`CAST]!enlist("CAST";"AS";"MIXED LIST"); \n ' +
' gr:enlist[`CAST]!enlist("CAST";"AS";"MIXED LIST"); \n ' +
Expand Down
2 changes: 1 addition & 1 deletion dist/model/query-param.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export declare class QueryParam {
column: any[];
where: string[];
temporal_field: any;
temporal_range: Date[];
temporal_range: number[];
grouping: string[];
conflation: any;
query: QueryDictionary;
Expand Down
2 changes: 1 addition & 1 deletion dist/model/query-param.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/model/query-param.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class QueryParam {
column: any[] = [];
where: string[] = [];
temporal_field: any;
temporal_range: Date[] = [];
temporal_range: number[] = [];
grouping: string[] = [];
conflation: any;
query: QueryDictionary;
Expand Down
2 changes: 1 addition & 1 deletion dist/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"small": "img/aquaq_logo.png",
"large": "img/aquaq_logo.png"
},
"version": "1.0.0"
"version": "1.0.1"
},
"alerting": true,
"annotations": false,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aquaq-kdb-datasource",
"version": "1.0.0",
"name": "aquaqanalytics-kdbadaptor-datasource",
"version": "1.0.1",
"description": "Grafana plugin for visualisation of data from kdb+ servers.",
"scripts": {
"build": "grunt",
Expand Down
12 changes: 8 additions & 4 deletions src/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { QueryParam } from "./model/query-param";
import { QueryDictionary } from "./model/queryDictionary";
import { ConflationParams } from "./model/conflationParams";
import { graphFunction } from './model/kdb-request-config';
import { tabFunction,defaultTimeout } from './model/kdb-request-config';
import { tabFunction,defaultTimeout,kdbEpoch } from './model/kdb-request-config';
export class KDBDatasource {
//This is declaring the types of each member
id: any;
Expand Down Expand Up @@ -146,11 +146,15 @@ export class KDBDatasource {
};
};

private buildKdbTimestamp(date : Date) {
return 1000000 * (date.valueOf() - kdbEpoch);
}

private buildTemporalRange(range) {
let temporalRange: Date[] = [];
let temporalRange: number[] = [];
if (range) {
temporalRange.push(new Date(range.from._d));
temporalRange.push(new Date(range.to._d));
temporalRange.push(this.buildKdbTimestamp(range.from._d));
temporalRange.push(this.buildKdbTimestamp(range.to._d));
}
return temporalRange;
};
Expand Down
3 changes: 3 additions & 0 deletions src/model/kdb-request-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//The default for the number
export const defaultRowCountLimit : number = 10000;
export var defaultTimeout : number = 5000;
export const kdbEpoch : number = 946684800000

//Graph response type
export const graphFunction: string = '{@[x;y;{`payload`error`success!(();"Error! - ",x;0b)}]}{[dict] \n ' +
Expand Down Expand Up @@ -73,6 +74,7 @@ export const graphFunction: string = '{@[x;y;{`payload`error`success!(();"Error
' (dict[`queryParam;`maxRowCount];dict[`queryId]); \n ' +
' \n ' +
' d:dict`queryParam; \n ' +
' d[`temporal_range]:`timestamp$d[`temporal_range]; \n ' +
' qt:d[`query;`type]; \n ' +
' funcparts:enlist[`CAST]!enlist("CAST";"AS";"MIXED LIST"); \n ' +
' gr:enlist[`CAST]!enlist("CAST";"AS";"MIXED LIST"); \n ' +
Expand Down Expand Up @@ -248,6 +250,7 @@ export const tabFunction: string = '{@[x;y;{`payload`error`success!(();"Error! -
' (dict[`queryParam;`maxRowCount];dict[`queryId]); \n ' +
' \n ' +
' d:dict`queryParam; \n ' +
' d[`temporal_range]:`timestamp$d[`temporal_range]; \n ' +
' qt:d[`query;`type]; \n ' +
' funcparts:enlist[`CAST]!enlist("CAST";"AS";"MIXED LIST"); \n ' +
' gr:enlist[`CAST]!enlist("CAST";"AS";"MIXED LIST"); \n ' +
Expand Down
Loading

0 comments on commit 8481a23

Please sign in to comment.