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

Show warning notification when sorting in asc order by count in term agg #8050

Merged
merged 7 commits into from
Aug 23, 2016

Conversation

ycombinator
Copy link
Contributor

Resolves #6833

If the user tries to use a Terms aggregation and sort in Ascending order of Count, a warning toast notification is shown.

@ycombinator ycombinator assigned epixa and spalger and unassigned epixa Aug 23, 2016
@ycombinator
Copy link
Contributor Author

Hey @spalger for some reason I'm seeing two warning notifications. It appears that the write function is being called twice.

@epixa
Copy link
Contributor

epixa commented Aug 23, 2016

I wonder if that's related to #7960

@epixa
Copy link
Contributor

epixa commented Aug 23, 2016

Or more specifically, #7945

@epixa epixa added the v4.6.0 label Aug 23, 2016
@ycombinator
Copy link
Contributor Author

Yeah, it would seem so. I'm testing it out...

@spalger
Copy link
Contributor

spalger commented Aug 23, 2016

Actually, the write function is called on both sides of an elasticsearch request.

@ycombinator
Copy link
Contributor Author

ycombinator commented Aug 23, 2016

Yeah, it would seem so. I'm testing it out...

No, that doesn't appear to be it. I backported those changes in my local copy and I still see the double notifications.

@spalger
Copy link
Contributor

spalger commented Aug 23, 2016

AggType#write() is called all the time honestly. If we don't want the notifications to just stack up (which I'm okay with) then we should debounce the notification some other way.

@ycombinator
Copy link
Contributor Author

Actually, the write function is called on both sides of an elasticsearch request.

Maybe I should just have a check to show the notification on one of those calls then?

@spalger
Copy link
Contributor

spalger commented Aug 23, 2016

I'm fine with the counter incrementing by 2, personally

const orderBy = orderAgg.type.name;
const sortOrder = agg.params.order.val;
if (orderBy === 'count' && sortOrder === 'asc') {
const notify = new Notifier();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we keep this at a higher scope? No reason to recreate it all the time. Perhaps you could also use this as a way to debounce the calls...

@spalger
Copy link
Contributor

spalger commented Aug 23, 2016

two totally minor things

@spalger spalger removed their assignment Aug 23, 2016
@spalger
Copy link
Contributor

spalger commented Aug 23, 2016

LGTM

1 similar comment
@ppisljar
Copy link
Member

LGTM

@ycombinator
Copy link
Contributor Author

ycombinator commented Aug 23, 2016

@spalger @ppisljar Thanks for reviewing. I wasn't too happy about the double notification so I looked into this some more. With the latest commit (d78eb51) I was able to conditionally append "[DEPRECATED]" to the "Ascending" select list option itself, when the terms aggregation was being ordered by Count.

What do you think of this solution?

@ppisljar
Copy link
Member

i like (prefer) this solution as i am able to see the option is deprecated before clicking "go" ...

LGTM

@spalger
Copy link
Contributor

spalger commented Aug 23, 2016

The main reason I suggested using notifications is to warn anyone using the visualization. Modifying the option display text only warns the user when they are creating the visualization. IMO the deprecation warning should be loud, and hard to miss, else people will just ignore it and their visualization will break when they upgrade (This is why I'm fine with the repeating).

Also, I don't think it's a good idea to change the display text for the order agg in the controller used for the editor of that agg. The directive code shouldn't be reaching in and changing the visType definition, which should be treated as immutable.

@ycombinator
Copy link
Contributor Author

ycombinator commented Aug 23, 2016

Ah yes, good point about notifying users already using the visualization. I'll revert my last two commits and merge. Thanks again both of you!

@ycombinator ycombinator merged commit b95eeda into elastic:4.x Aug 23, 2016
@ycombinator ycombinator deleted the deprecate-asc-count-terms branch August 23, 2016 08:25
@epixa
Copy link
Contributor

epixa commented Aug 23, 2016

I think this notification is too chatty to ship like this. If you have the visualization on a dashboard with autorefresh enabled, it fires the notification on each interval, which means it would be practically impossible to have this visualization on a dashboard without constantly nagging about it. I'd much prefer a more detailed error message that encourages people to switch to desc that happens only once per route change or something.

@ycombinator
Copy link
Contributor Author

I think making the notification trigger only once per route change shouldn't be too difficult.

@ycombinator ycombinator restored the deprecate-asc-count-terms branch August 23, 2016 13:42
@ycombinator ycombinator deleted the deprecate-asc-count-terms branch August 23, 2016 13:43
@epixa epixa changed the title Show warning notification when sorting in desc order by count in term agg Show warning notification when sorting in asc order by count in term agg Aug 23, 2016
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