Skip to content

Commit

Permalink
feat: 只允许聚合一次
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtao25 committed Oct 10, 2023
1 parent 5fbdd17 commit fccf129
Showing 1 changed file with 32 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ export class TriggerAggCoverageService {
async invoke(params) {
let { report_id } = params;
const { pkgId } = params;
const tasks = await this.prisma.task
.findMany({
where: {
type: 'coverageagg',
},
})
.then((res) =>
res.filter((i: any) => i.data.report_id === params.report_id),
);
if (pkgId) {
try {
report_id = await axios
Expand Down Expand Up @@ -39,24 +48,30 @@ export class TriggerAggCoverageService {
code: 0,
};
}

await this.prisma.task.create({
data: {
name: `Coverage Agg Task ${report_id}`,
status: 'notstarted',
type: 'coverageagg',
if (tasks.length > 0) {
return {
msg: '该报告已聚合',
data: [],
code: -1,
};
} else {
await this.prisma.task.create({
data: {
report_id: report_id,
name: `Coverage Agg Task ${report_id}`,
status: 'notstarted',
type: 'coverageagg',
data: {
report_id: report_id,
},
result: {},
logs: [],
},
result: {},
logs: [],
},
});

return {
msg: '聚合中',
data: [],
code: 1,
};
});
return {
msg: '聚合中',
data: [],
code: 1,
};
}
}
}

0 comments on commit fccf129

Please sign in to comment.