Skip to content
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

[FieldFormats] Reduce any usage #111530

Merged
merged 15 commits into from
Sep 13, 2021
Merged

Conversation

Dosant
Copy link
Contributor

@Dosant Dosant commented Sep 8, 2021

Summary

This reduces any usage in field formats code tackling lower hanging occurrences

There is still a larger effort needed to improve types and get rid of any completely #108158. This needs more time to tackle (needs field formats public API change and then needs a bunch of downstream changes) and I am out of timeboxed time here already.

@Dosant Dosant force-pushed the d/2021-08-26-ff-any branch from bb9d392 to 7033024 Compare September 9, 2021 14:46
@Dosant Dosant changed the title wip reduce any in ff [FieldFormats] Reduce any usage Sep 10, 2021
@@ -828,7 +828,7 @@ export class SearchSource {
body.query = buildEsQuery(index, query, filters, esQueryConfigs);

if (highlightAll && body.query) {
body.highlight = getHighlightRequest(body.query, getConfig(UI_SETTINGS.DOC_HIGHLIGHT));
body.highlight = getHighlightRequest(getConfig(UI_SETTINGS.DOC_HIGHLIGHT));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getHighlightRequest didn't use query inside, so I decided to remove it from the function signature to remove any.
@lukasolson, could you review this one? Maybe this wasn't correct in the first place that query is not used inside getHighlightRequest

@@ -20,7 +20,7 @@ export class BoolFormat extends FieldFormat {
});
static fieldType = [KBN_FIELD_TYPES.BOOLEAN, KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.STRING];

textConvert: TextContextTypeConvert = (value) => {
textConvert: TextContextTypeConvert = (value: string | number | boolean) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all of these formatters, I just specified types based on what I saw is supported in runtime

const fracSecMatchStr = fracSecMatch ? fracSecMatch[0] : '';

return {
length: fracSecMatchStr.length,
patternNanos: fracSecMatchStr,
pattern,
patternEscaped: fracSecMatchStr ? pattern.replace(fracSecMatch, `[${fracSecMatch}]`) : '',
patternEscaped: fracSecMatchStr ? pattern.replace(fracSecMatchStr, `[${fracSecMatchStr}]`) : '',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kertal, could you review this change please 🙏 (this was added by you in the past #43114)
when removing any typescript screamed that something was wrong here and I changed assuming this was a bug

return this.getDefaultInstanceMemoized(fieldType, esTypes, params);
};

private getDefaultInstanceMemoized = memoize(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extracting memoized methods to not expose types from memoize publicly

@Dosant Dosant added Feature:FieldFormatters release_note:skip Skip the PR/issue when compiling release notes Team:AppServices technical debt Improvement of the software architecture and operational architecture v7.16.0 v8.0.0 labels Sep 10, 2021
@Dosant Dosant marked this pull request as ready for review September 10, 2021 15:08
@Dosant Dosant requested review from a team as code owners September 10, 2021 15:08
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-services (Team:AppServices)

Copy link
Member

@lukasolson lukasolson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes LGTM, didn't test

Copy link
Contributor

@mattkime mattkime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work!

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review only. Kibana vis editors team changes LGTM!

@kertal
Copy link
Member

kertal commented Sep 13, 2021

@elasticmachine merge upstream

Copy link
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Data Discover LGTM, just review, only types changed

@Dosant
Copy link
Contributor Author

Dosant commented Sep 13, 2021

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
fieldFormats 233 250 +17

Any counts in public APIs

Total count of every any typed public API. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats any for more detailed information.

id before after diff
fieldFormats 26 7 -19

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
fieldFormats 10 3 -7

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
data 777.9KB 777.8KB -11.0B
fieldFormats 73.7KB 75.2KB +1.6KB
total +1.5KB
Unknown metric groups

API count

id before after diff
fieldFormats 263 288 +25

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@Dosant Dosant added the auto-backport Deprecated - use backport:version if exact versions are needed label Sep 13, 2021
@Dosant Dosant merged commit d6badd8 into elastic:master Sep 13, 2021
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Sep 13, 2021
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed Feature:FieldFormatters release_note:skip Skip the PR/issue when compiling release notes technical debt Improvement of the software architecture and operational architecture v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants