Use destruturing assignment to format the formula result
This commit is contained in:
parent
ecbc7a28e7
commit
c00a93f414
@ -103,23 +103,20 @@ module.exports = class Formula extends BaseDataview {
|
||||
}
|
||||
|
||||
format (result) {
|
||||
var formattedResult = {
|
||||
const {
|
||||
result = 0,
|
||||
nulls_count = 0,
|
||||
nans_count = 0,
|
||||
infinities_count = 0
|
||||
} = result.rows[0] || {};
|
||||
|
||||
return {
|
||||
operation: this.operation,
|
||||
result: 0,
|
||||
nulls: 0,
|
||||
nans: 0,
|
||||
infinities: 0
|
||||
result,
|
||||
nulls: nulls_count,
|
||||
nans: nans_count,
|
||||
infinities: infinities_count
|
||||
};
|
||||
|
||||
if (result.rows.length) {
|
||||
formattedResult.operation = this.operation;
|
||||
formattedResult.result = result.rows[0].result;
|
||||
formattedResult.nulls = result.rows[0].nulls_count;
|
||||
formattedResult.nans = result.rows[0].nans_count;
|
||||
formattedResult.infinities = result.rows[0].infinities_count;
|
||||
}
|
||||
|
||||
return formattedResult;
|
||||
}
|
||||
|
||||
getType () {
|
||||
|
Loading…
Reference in New Issue
Block a user