Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
mbondyra committed Aug 18, 2020
1 parent fcd423f commit f01ce2d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions x-pack/plugins/lens/public/indexpattern_datasource/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ export async function loadIndexPatterns({
}

const indexPatterns = await Promise.all(missingIds.map((id) => indexPatternsService.get(id)));

const indexPatternsObject = indexPatterns.reduce(
(acc, indexPattern) => {
const newFields = indexPattern.fields
const newFields = (indexPattern.fields as IndexPatternField[])
.filter(
(field) =>
!indexPatternsUtils.isNestedField(field) && (!!field.aggregatable || !!field.scripted)
Expand All @@ -68,7 +67,7 @@ export async function loadIndexPatterns({
)
.concat(documentField);

const { typeMeta } = indexPattern;
const { typeMeta, title, timeFieldName, fieldFormatMap } = indexPattern;
if (typeMeta?.aggs) {
const aggs = Object.keys(typeMeta.aggs);
newFields.forEach((field, index) => {
Expand All @@ -86,10 +85,13 @@ export async function loadIndexPatterns({
});
}

const currentIndexPattern = {
...indexPattern,
const currentIndexPattern: IndexPattern = {
id: indexPattern.id!, // id exists for sure because we got index patterns by id
title,
timeFieldName,
fieldFormatMap,
fields: newFields,
} as IndexPattern;
};

return {
[currentIndexPattern.id]: currentIndexPattern,
Expand Down

0 comments on commit f01ce2d

Please sign in to comment.