-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial pass at limiting agg types based on rollup caps
- Loading branch information
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import './register'; |
32 changes: 32 additions & 0 deletions
32
x-pack/plugins/rollup/public/vis_type_agg_filter/register.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { aggTypeFilters } from 'ui/agg_types/filter'; | ||
import { uniq } from 'lodash'; | ||
|
||
/** | ||
* If rollup index pattern, check its capabilities | ||
* and limit available aggregations based on that. | ||
*/ | ||
aggTypeFilters.addFilter( | ||
(aggType, indexPattern) => { | ||
if(indexPattern.type !== 'rollup') { | ||
return true; | ||
} | ||
|
||
const jobs = indexPattern.typeMeta.jobs; | ||
let allAggs = []; | ||
|
||
jobs.forEach(job => { | ||
const fields = indexPattern.typeMeta.capabilities[job].fields; | ||
Object.keys(fields).forEach(field => { | ||
allAggs = [...allAggs, ...fields[field].map(agg => agg.agg)]; | ||
}); | ||
}); | ||
|
||
return uniq(allAggs).includes(aggType.name); | ||
} | ||
); |