[Rollups] Fix time field not being recognized due to ordering of aggs (#24783) (#24799)

* Fix time field not being recognized due to ordering of aggs

* Clean up UI whitespace

* Update snapshot
This commit is contained in:
Jen Huang 2018-10-30 00:01:30 -07:00 committed by GitHub
parent 758f158d4d
commit fef9624357
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 25 deletions

View file

@ -2,9 +2,6 @@
exports[`Header should render normally 1`] = `
<div>
<EuiSpacer
size="m"
/>
<EuiTitle
size="m"
>
@ -59,9 +56,6 @@ exports[`Header should render normally 1`] = `
exports[`Header should render without including system indices 1`] = `
<div>
<EuiSpacer
size="m"
/>
<EuiTitle
size="m"
>

View file

@ -39,7 +39,6 @@ export const Header = ({
onChangeIncludingSystemIndices,
}) => (
<div>
<EuiSpacer size="m"/>
<EuiTitle>
<h1>
<FormattedMessage

View file

@ -3,7 +3,6 @@
<div
ng-controller="managementIndicesEdit"
data-test-subj="editIndexPattern"
class="kuiViewContent"
role="region"
aria-label="{{::'kbn.management.editIndexPattern.detailsAria' | i18n: { defaultMessage: 'Index pattern details' } }}"
>

View file

@ -69,23 +69,44 @@ export function registerFieldsForWildcardRoute(server) {
readFromDocValues: true,
};
rollupFields.push(
...fields
// For each field of the aggregation, filter out ones that have already been added
// to the field list bcause the same field can be part of multiple aggregations, but
// end consumption doesn't differentiate fields based on their aggregation abilities.
.filter(field => !rollupFieldNames.includes(field))
// Then expand each field into object format that end consumption expects.
.map(field => {
const fieldCapsKey = `${field}.${agg}.${agg === 'date_histogram' ? 'timestamp' : 'value'}`;
rollupFieldNames.push(field);
return {
...fieldsFromFieldCapsApi[fieldCapsKey],
...defaultField,
name: field,
};
})
);
// Date histogram agg only ever has one field defined, let date type overwrite a
// previous type if defined (such as number from max and min aggs).
if(agg === 'date_histogram') {
const timeFieldName = fields[0];
const fieldCapsKey = `${timeFieldName}.${agg}.timestamp`;
const newField = {
...fieldsFromFieldCapsApi[fieldCapsKey],
...defaultField,
name: timeFieldName,
};
const existingField = rollupFields.find(field => field.name === timeFieldName);
if(existingField) {
Object.assign(existingField, newField);
} else {
rollupFieldNames.push(timeFieldName);
rollupFields.push(newField);
}
}
// For all other aggs, filter out ones that have already been added to the field list
// because the same field can be part of multiple aggregations, but end consumption
// doesn't differentiate fields based on their aggregation abilities.
else {
rollupFields.push(
...fields
.filter(field => !rollupFieldNames.includes(field))
.map(field => {
// Expand each field into object format that end consumption expects.
const fieldCapsKey = `${field}.${agg}.value`;
rollupFieldNames.push(field);
return {
...fieldsFromFieldCapsApi[fieldCapsKey],
...defaultField,
name: field,
};
})
);
}
});
return {