mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Lens] Reduce call stack for formula (#171744)
## Summary
Reduce a bit the call stack with associated perf speedup in a scenario
with many fields.
*Note*: initially I've optimize somehow the memoization of
`getAvailableOperationsByMetadata` but it was too brittle as changing
something in the dataview leads to wrong results. I'm not sure this
could actually happen in real life ™️ but a test hijacking a bit a
dataView found that out.
This commit is contained in:
parent
62d0ce4c7c
commit
545e472d8f
1 changed files with 10 additions and 10 deletions
|
@ -215,18 +215,18 @@ export function getPossibleFunctions(
|
|||
operationDefinitionMap?: Record<string, GenericOperationDefinition>
|
||||
) {
|
||||
const available = memoizedGetAvailableOperationsByMetadata(indexPattern, operationDefinitionMap);
|
||||
const possibleOperationNames: string[] = [];
|
||||
available.forEach((a) => {
|
||||
const possibleOperationNames: Set<string> = new Set();
|
||||
for (const a of available) {
|
||||
if (a.operationMetaData.dataType === 'number' && !a.operationMetaData.isBucketed) {
|
||||
possibleOperationNames.push(
|
||||
...a.operations
|
||||
.filter((o) => o.type !== 'managedReference' || o.usedInMath)
|
||||
.map((o) => o.operationType)
|
||||
);
|
||||
for (const o of a.operations) {
|
||||
if (o.type !== 'managedReference' || o.usedInMath) {
|
||||
possibleOperationNames.add(o.operationType);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return [...uniq(possibleOperationNames), ...Object.keys(tinymathFunctions)];
|
||||
return Array.from(possibleOperationNames.keys()).concat(Object.keys(tinymathFunctions));
|
||||
}
|
||||
|
||||
function getFunctionSuggestions(
|
||||
|
@ -261,7 +261,7 @@ function getArgumentSuggestions(
|
|||
if (tinymathFunction) {
|
||||
if (tinymathFunction.positionalArguments[position]) {
|
||||
return {
|
||||
list: uniq(getPossibleFunctions(indexPattern, operationDefinitionMap)).map((f) => ({
|
||||
list: getPossibleFunctions(indexPattern, operationDefinitionMap).map((f) => ({
|
||||
type: 'math' as const,
|
||||
label: f,
|
||||
})),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue