-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding timeshift units #61
Conversation
@@ -38,6 +38,8 @@ export class MetaQueriesQueryCtrl extends QueryCtrl { | |||
|
|||
defaultPeriods = 7; | |||
|
|||
defaultUnit = "days"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default helps not breaking existing ones
src/query_ctrl.ts
Outdated
@@ -52,6 +54,9 @@ export class MetaQueriesQueryCtrl extends QueryCtrl { | |||
if (!this.target.periods) { | |||
this.clearPeriods(); | |||
} | |||
if (!this.target.units) { | |||
this.target.units = this.defaultUnit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
src/query_ctrl.ts
Outdated
@@ -52,6 +54,9 @@ export class MetaQueriesQueryCtrl extends QueryCtrl { | |||
if (!this.target.periods) { | |||
this.clearPeriods(); | |||
} | |||
if (!this.target.units) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
calling this timeshiftUnit
might be better. I do understand existing code doesn't do it for periods but would love to scope it to type unless its generic. keeping in mind about stddev etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@rasinhas thanks for the PR |
fixes #22 |
@@ -248,7 +249,7 @@ function (angular, _, dateMath, moment) { | |||
data.forEach(function (datum) { | |||
if(datum.target===metric){ | |||
datum.datapoints.forEach(function (datapoint) { | |||
datapoint[1] = dateToMoment(new Date(datapoint[1]),false).subtract(periodsToShift,'days').toDate().getTime(); | |||
datapoint[1] = dateToMoment(new Date(datapoint[1]),false).subtract(periodsToShift,unit).toDate().getTime(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed looking at this, can you fix variables and raise another PR ?
@@ -221,9 +221,10 @@ function (angular, _, dateMath, moment) { | |||
var periodsToShift = target.periods; | |||
var query = target.query; | |||
var metric = target.metric; | |||
var unit = target.unit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
@@ -38,6 +38,8 @@ export class MetaQueriesQueryCtrl extends QueryCtrl { | |||
|
|||
defaultPeriods = 7; | |||
|
|||
defaultUnit = "days"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaultTimeShiftUnit
Added a dropdown element to enable changing the period unit on timeshift.
Unit options are: seconds, minutes, hours, days, weeks and months.