mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
fix(plugin-workflow-aggregate): fix round on null result (#6473)
This commit is contained in:
parent
2fd8cf44b7
commit
e1f7e94e0d
@ -49,7 +49,7 @@ export default class extends Instruction {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
result: round(options.dataType === DataTypes.DOUBLE ? Number(result) : result, 14),
|
result: round((options.dataType === DataTypes.DOUBLE ? Number(result) : result) || 0, 14),
|
||||||
status: JOB_STATUS.RESOLVED,
|
status: JOB_STATUS.RESOLVED,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -180,6 +180,27 @@ describe('workflow > instructions > aggregate', () => {
|
|||||||
expect(j2.result).toBe(0.3);
|
expect(j2.result).toBe(0.3);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('sum null will be 0', async () => {
|
||||||
|
const n1 = await workflow.createNode({
|
||||||
|
type: 'aggregate',
|
||||||
|
config: {
|
||||||
|
aggregator: 'sum',
|
||||||
|
collection: 'posts',
|
||||||
|
params: {
|
||||||
|
field: 'read',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const p2 = await PostRepo.create({ values: { title: 't2' } });
|
||||||
|
|
||||||
|
await sleep(500);
|
||||||
|
|
||||||
|
const [e1] = await workflow.getExecutions();
|
||||||
|
const [j1] = await e1.getJobs();
|
||||||
|
expect(j1.result).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
it('avg', async () => {
|
it('avg', async () => {
|
||||||
const n1 = await workflow.createNode({
|
const n1 = await workflow.createNode({
|
||||||
type: 'aggregate',
|
type: 'aggregate',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user