Skip to content
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

Merged
merged 4 commits into from
Jun 25, 2019
Merged

Adding timeshift units #61

merged 4 commits into from
Jun 25, 2019

Conversation

rasinhas
Copy link
Contributor

Added a dropdown element to enable changing the period unit on timeshift.

Unit options are: seconds, minutes, hours, days, weeks and months.

timeshiftdd

@@ -38,6 +38,8 @@ export class MetaQueriesQueryCtrl extends QueryCtrl {

defaultPeriods = 7;

defaultUnit = "days";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

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

@@ -52,6 +54,9 @@ export class MetaQueriesQueryCtrl extends QueryCtrl {
if (!this.target.periods) {
this.clearPeriods();
}
if (!this.target.units) {
this.target.units = this.defaultUnit;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -52,6 +54,9 @@ export class MetaQueriesQueryCtrl extends QueryCtrl {
if (!this.target.periods) {
this.clearPeriods();
}
if (!this.target.units) {
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@Gauravshah
Copy link
Member

@rasinhas thanks for the PR

@Gauravshah
Copy link
Member

fixes #22

@Gauravshah Gauravshah merged commit 193a029 into GoshPosh:master Jun 25, 2019
@@ -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();
Copy link
Member

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;
Copy link
Member

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";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultTimeShiftUnit

@Gauravshah
Copy link
Member

Gauravshah commented Jun 25, 2019

@rasinhas I have reverted the code changes on master. Opened a new PR #62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants