-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Data View Field] Fix popularity score bugs #211201
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
Changes from all commits
0aad1a4
598f3de
6fa5d4d
bd3ef1d
4ef4354
eeacf4a
91978a4
3421be1
1eaa32d
885ba5f
d87f207
f79545d
a59d482
f2bfbe3
7b1efba
7af1687
9e605b3
db47f5c
9a29c06
e4333a3
60339a6
0ec138d
05b327f
83b214c
beb2d05
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -365,8 +365,15 @@ export abstract class AbstractDataView { | |
| getAsSavedObjectBody(): DataViewAttributes { | ||
| const stringifyOrUndefined = (obj: any) => (obj ? JSON.stringify(obj) : undefined); | ||
|
|
||
| const fieldAttrsWithValues: Record<string, FieldAttrSet> = {}; | ||
| this.fieldAttrs.forEach((attrs, fieldName) => { | ||
| if (Object.keys(attrs).length) { | ||
| fieldAttrsWithValues[fieldName] = attrs; | ||
| } | ||
| }); | ||
|
Comment on lines
+368
to
+373
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious which issue this addresses? I couldn't tell from the code.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @davismcphee To make the output smaller. For example, instead of |
||
|
|
||
| return { | ||
| fieldAttrs: stringifyOrUndefined(Object.fromEntries(this.fieldAttrs.entries())), | ||
| fieldAttrs: stringifyOrUndefined(fieldAttrsWithValues), | ||
| title: this.getIndexPattern(), | ||
| timeFieldName: this.timeFieldName, | ||
| sourceFilters: stringifyOrUndefined(this.sourceFilters), | ||
|
|
@@ -382,8 +389,10 @@ export abstract class AbstractDataView { | |
| } | ||
|
|
||
| protected toSpecShared(includeFields = true): DataViewSpec { | ||
| // `cloneDeep` is added to make sure that the original fieldAttrs map is not modified with the following `delete` operation. | ||
| const fieldAttrs = cloneDeep(Object.fromEntries(this.fieldAttrs.entries())); | ||
|
Comment on lines
+392
to
+393
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for explaining! I was both thinking |
||
|
|
||
| // if fields aren't included, don't include count | ||
| const fieldAttrs = Object.fromEntries(this.fieldAttrs.entries()); | ||
| if (!includeFields) { | ||
| Object.keys(fieldAttrs).forEach((key) => { | ||
| delete fieldAttrs[key].count; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like a flaw in the data view lazy implementation that we have to do this. Maybe we should consider clearing the corresponding lazy cache instance internally whenever a regular data view is saved, and vice versa. But this probably needs more investigation and it would be great to get this fixed, so this should be fine for now.