Skip to content

Commit

Permalink
improved parameters name and changed aggregation from latest to top t…
Browse files Browse the repository at this point in the history
…o better reflect what this aggregation may accomplish
  • Loading branch information
scampi committed Oct 11, 2016
1 parent 9791ac5 commit 692f41c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

<select
class="form-control"
name="sort"
name="sortField"
required
ng-model="agg.params.sort"
ng-model="agg.params.sortField"
ng-show="indexedFields.length"
auto-select-if-only-one="indexedFields"
ng-options="field as field.displayName group by field.type for field in indexedFields">
Expand All @@ -20,8 +20,8 @@
</label>

<select
name="order"
ng-model="agg.params.order"
name="sortOrder"
ng-model="agg.params.sortOrder"
required
ng-options="opt as opt.display for opt in aggParam.options"
class="form-control">
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/agg_types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import AggTypesMetricsSumProvider from 'ui/agg_types/metrics/sum';
import AggTypesMetricsMedianProvider from 'ui/agg_types/metrics/median';
import AggTypesMetricsMinProvider from 'ui/agg_types/metrics/min';
import AggTypesMetricsMaxProvider from 'ui/agg_types/metrics/max';
import AggTypesMetricsLatestProvider from 'ui/agg_types/metrics/latest';
import AggTypesMetricsTopProvider from 'ui/agg_types/metrics/top';
import AggTypesMetricsStdDeviationProvider from 'ui/agg_types/metrics/std_deviation';
import AggTypesMetricsCardinalityProvider from 'ui/agg_types/metrics/cardinality';
import AggTypesMetricsPercentilesProvider from 'ui/agg_types/metrics/percentiles';
Expand Down Expand Up @@ -34,7 +34,7 @@ export default function AggTypeService(Private) {
Private(AggTypesMetricsCardinalityProvider),
Private(AggTypesMetricsPercentilesProvider),
Private(AggTypesMetricsPercentileRanksProvider),
Private(AggTypesMetricsLatestProvider)
Private(AggTypesMetricsTopProvider)
],
buckets: [
Private(AggTypesBucketsDateHistogramProvider),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { noop, get } from 'lodash';
import AggTypesMetricsMetricAggTypeProvider from 'ui/agg_types/metrics/metric_agg_type';
import latestEditor from 'ui/agg_types/controls/latest.html';
import topEditor from 'ui/agg_types/controls/top.html';

export default function AggTypeMetricAvgProvider(Private) {
export default function AggTypeMetricTopProvider(Private) {
let MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider);

return new MetricAggType({
name: 'top_hits',
title: 'Latest',
title: 'Top',
makeLabel: function (aggConfig) {
return 'Latest ' + aggConfig.params.field.displayName;
const prefix = aggConfig.params.sortOrder.val === 'desc' ? 'Latest' : 'Earliest';
return `${prefix} ${aggConfig.params.field.displayName}`;
},
params: [
{
Expand All @@ -22,7 +23,7 @@ export default function AggTypeMetricAvgProvider(Private) {
}
},
{
name: 'sort',
name: 'sortField',
type: 'field',
editor: null,
filterFieldTypes: ['number', 'date', 'ip', 'string'],
Expand All @@ -32,19 +33,19 @@ export default function AggTypeMetricAvgProvider(Private) {
write: noop // prevent default write, it is handled below
},
{
name: 'order',
name: 'sortOrder',
type: 'optioned',
default: 'desc',
editor: latestEditor,
editor: topEditor,
options: [
{ display: 'Descending', val: 'desc' },
{ display: 'Ascending', val: 'asc' }
],
write(agg, output) {
output.params.sort = [
{
[ agg.params.sort.name ]: {
order: agg.params.order.val
[ agg.params.sortField.name ]: {
order: agg.params.sortOrder.val
}
}
];
Expand Down

0 comments on commit 692f41c

Please sign in to comment.