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

Map date histogram values from 4.0 format to 4.1 format #4150

Merged
merged 3 commits into from
Jun 9, 2015

Conversation

lukasolson
Copy link
Member

The format in which date histogram intervals are saved was changed in #3237. This caused issues with upgrading from 4.0 to 4.1, as the intervals would be lost and it would automatically revert to auto.

This PR maps old values to the new values by comparing if the two are equal according to moment.duration:

return Number(moment.duration(1, state)) === Number(moment.duration(1, option.val));

This works for all previous options: second, minute, hour, day, week, month, year.

However, when a user goes to save a visualization, it will overwrite it with the new format (s, m, h, d, w, M, y).

Closes #4149.

deserialize: function (state, agg) {
var interval = _.find(intervalOptions, {val: state});
return interval || _.find(intervalOptions, function (option) {
// For upgrading from 4.0.x to 4.1.x - intervals are now stored as 'y' instead of 'year',
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you scoot this left two-spaces?

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops. Stupid IntelliJ.

@@ -71,8 +72,16 @@ define(function (require) {
{
name: 'interval',
type: 'optioned',
deserialize: function (state, agg) {
Copy link
Contributor

Choose a reason for hiding this comment

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

agg isn't being used, it can be removed

@w33ble
Copy link
Contributor

w33ble commented Jun 9, 2015

This has a side effect of defaulting back to auto when the state is an invalid value, since both values end up being cast to 0. Nice!

@w33ble w33ble assigned lukasolson and unassigned rashidkpc Jun 9, 2015
@lukasolson lukasolson assigned w33ble and unassigned lukasolson Jun 9, 2015
@w33ble
Copy link
Contributor

w33ble commented Jun 9, 2015

🈺 ship it ™️ 🈚

w33ble added a commit that referenced this pull request Jun 9, 2015
Map date histogram values from 4.0 format to 4.1 format
@w33ble w33ble merged commit 4557a6f into elastic:master Jun 9, 2015
@lukasolson lukasolson deleted the issues/4149 branch February 11, 2016 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants