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

Add year interval for DateHistogramFacet #1502

Merged
merged 3 commits into from
Jul 13, 2021

Conversation

nrsimha
Copy link
Contributor

@nrsimha nrsimha commented May 2, 2021

Added year interval for DateHistogramFacet.

Closes #1501

@nrsimha
Copy link
Contributor Author

nrsimha commented Jul 7, 2021

Is there anything I can do to make this merged?

Copy link
Contributor

@sethmlarson sethmlarson left a comment

Choose a reason for hiding this comment

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

Thanks for this, one comment for you:

@@ -168,6 +168,10 @@ def get_value_filter(self, filter_value):
)


def _date_interval_year(d):
return (d + timedelta(days=366)).replace(day=1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's change this to return d.replace(year=d.year+1, day=(28 if d.month == 2 and d.day == 29 else d.day)) since years are linear unlike months.

We should add a test case for leap day handling as well (Basically see that February 29th, 2020 increments to February 28th, 2021)

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. Updated to return d.replace(year=d.year+1, day=(28 if d.month == 2 and d.day == 29 else d.day))

@nrsimha nrsimha requested a review from sethmlarson July 13, 2021 17:04
Copy link
Contributor

@sethmlarson sethmlarson left a comment

Choose a reason for hiding this comment

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

LGTM

@sethmlarson sethmlarson merged commit 1ac597f into elastic:master Jul 13, 2021
@nrsimha
Copy link
Contributor Author

nrsimha commented Jul 15, 2021

Thank you

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.

Add 'year' to date intervals for DateHistogramFacet
2 participants