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
9 changes: 9 additions & 0 deletions src/ui/public/agg_types/buckets/terms.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Notifier from 'ui/notify/notifier';

define(function (require) {
return function TermsAggDefinition(Private) {
let _ = require('lodash');
Expand Down Expand Up @@ -130,6 +132,13 @@ define(function (require) {

let orderAgg = agg.params.orderAgg || vis.aggs.getResponseAggById(agg.params.orderBy);

const orderBy = orderAgg.type.name;
const sortOrder = agg.params.order.val;
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer sortOrder over dir, but I'm not a fan of two variables tracking the same thing.

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...

notify.warning('Sorting in Ascending order by Count in Terms aggregations is deprecated');
}

// TODO: This works around an Elasticsearch bug the always casts terms agg scripts to strings
// thus causing issues with filtering. This probably causes other issues since float might not
// be able to contain the number on the elasticsearch side
Expand Down