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) {
|
format (result) {
|
||||||
var formattedResult = {
|
const {
|
||||||
|
result = 0,
|
||||||
|
nulls_count = 0,
|
||||||
|
nans_count = 0,
|
||||||
|
infinities_count = 0
|
||||||
|
} = result.rows[0] || {};
|
||||||
|
|
||||||
|
return {
|
||||||
operation: this.operation,
|
operation: this.operation,
|
||||||
result: 0,
|
result,
|
||||||
nulls: 0,
|
nulls: nulls_count,
|
||||||
nans: 0,
|
nans: nans_count,
|
||||||
infinities: 0
|
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 () {
|
getType () {
|
||||||
|
Loading…
Reference in New Issue
Block a user