-
Notifications
You must be signed in to change notification settings - Fork 47
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
[IMP] evaluation: evaluateFormula
no longer throws
#3371
Conversation
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.
looking good 👍
Only 2 small questions
@@ -188,7 +184,7 @@ export class EvaluationConditionalFormatPlugin extends UIPlugin { | |||
return percentile(rangeValues, Number(threshold.value) / 100, true); | |||
case "formula": | |||
const value = threshold.value && this.getters.evaluateFormula(threshold.value); | |||
return !(value instanceof Promise) ? value : null; | |||
return typeof value == "number" ? value : null; |
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.
this is a behavior change, right ?
Technically, value
could be a string before (even if it should not according to the method return type).
Are we missing a test where the formula evaluates to a string ?
@@ -380,7 +376,7 @@ export class EvaluationConditionalFormatPlugin extends UIPlugin { | |||
if (cell && cell.evaluated.type === CellValueType.error) { | |||
return false; | |||
} | |||
const values = rule.values.map(parsePrimitiveContent); | |||
const values = rule.values?.map(parsePrimitiveContent) || []; |
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.
is this necessary ? The type definition states that values
is always defined. But maybe it's lying :p
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.
the data fed to Model
unfortunately bypasses it :/. I feel like TS could warn me that the chaining ?.
is unnecessary since values is always defined 🤔
810d949
to
ea6cd26
Compare
The getter `evaluateFormula` required to be wrapped in a try/catch statement to handle the evaluation errors but as this is quite error prone, we decided to change it to no longer throw. The getter will instead the value of the error that was previously thrown. Task: 3576149
ea6cd26
to
5627f50
Compare
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.
robodoo r+
The getter `evaluateFormula` required to be wrapped in a try/catch statement to handle the evaluation errors but as this is quite error prone, we decided to change it to no longer throw. The getter will instead the value of the error that was previously thrown. closes #3371 Task: 3576149 Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
The getter `getPivotCellFromPosition` parses pivot cells domain args but this step assumes that the domain is valid (e.g. refers to a valid groupby,measure combination). Unfortunately, if the domain is invalid, the parsing will crash. Similarly to the decision made for the getter `evaluateFormula`[^1] we wrap the parsing in a try/catch statement and in case of faulty evaluation, return the same result as for invalid/non-existing pivots, that is an empty Pivotcell. [^1]: See #3371 Task: 4088765
The getter `getPivotCellFromPosition` parses pivot cells domain args but this step assumes that the domain is valid (e.g. refers to a valid groupby,measure combination). Unfortunately, if the domain is invalid, the parsing will crash. Similarly to the decision made for the getter `evaluateFormula`[^1] we wrap the parsing in a try/catch statement and in case of faulty evaluation, return the same result as for invalid/non-existing pivots, that is an empty Pivotcell. [^1]: See #3371 closes #4741 Task: 4088765 Signed-off-by: Lucas Lefèvre (lul) <[email protected]>
The getter `getPivotCellFromPosition` parses pivot cells domain args but this step assumes that the domain is valid (e.g. refers to a valid groupby,measure combination). Unfortunately, if the domain is invalid, the parsing will crash. Similarly to the decision made for the getter `evaluateFormula`[^1] we wrap the parsing in a try/catch statement and in case of faulty evaluation, return the same result as for invalid/non-existing pivots, that is an empty Pivotcell. [^1]: See #3371 Task: 4088765 X-original-commit: 693db2b
The getter `getPivotCellFromPosition` parses pivot cells domain args but this step assumes that the domain is valid (e.g. refers to a valid groupby,measure combination). Unfortunately, if the domain is invalid, the parsing will crash. Similarly to the decision made for the getter `evaluateFormula`[^1] we wrap the parsing in a try/catch statement and in case of faulty evaluation, return the same result as for invalid/non-existing pivots, that is an empty Pivotcell. [^1]: See #3371 Task: 4088765 X-original-commit: 693db2b
The getter `getPivotCellFromPosition` parses pivot cells domain args but this step assumes that the domain is valid (e.g. refers to a valid groupby,measure combination). Unfortunately, if the domain is invalid, the parsing will crash. Similarly to the decision made for the getter `evaluateFormula`[^1] we wrap the parsing in a try/catch statement and in case of faulty evaluation, return the same result as for invalid/non-existing pivots, that is an empty Pivotcell. [^1]: See #3371 closes #4805 Task: 4088765 X-original-commit: 693db2b Signed-off-by: Lucas Lefèvre (lul) <[email protected]> Signed-off-by: Rémi Rahir (rar) <[email protected]>
The getter
evaluateFormula
required to be wrapped in a try/catch statement to handle the evaluation errors but as this is quite error prone, we decided to change it to no longer throw. The getter will instead the value of the error that was previously thrown.Task: 3576149
Description:
description of this task, what is implemented and why it is implemented that way.
Task: : TASK_ID
review checklist