|
@@ -10,10 +10,12 @@ class AppExceptionRecordService extends Service {
|
|
|
|
|
|
const agg = [
|
|
|
{ $match: ctx.helper.getTimeRangMatch(startTime, endTime) },
|
|
|
- { $group: ctx.helper.getTimeGroup(type, { total: { $sum: '$total' },
|
|
|
- sys_count: { $sum: '$sys_count' },
|
|
|
- interface_exception_count: { $sum: '$interface_exception_count' },
|
|
|
- }) },
|
|
|
+ { $group: ctx.helper.getTimeGroup(type,
|
|
|
+ { total: { $sum: '$total' },
|
|
|
+ sys_count: { $sum: '$sys_count' },
|
|
|
+ interface_exception_count: { $sum: '$interface_exception_count' },
|
|
|
+ }),
|
|
|
+ },
|
|
|
];
|
|
|
|
|
|
return await ctx.model.Local.AppExceptionRecordModel.aggregate(agg);
|
|
@@ -27,32 +29,35 @@ class AppExceptionRecordService extends Service {
|
|
|
return;
|
|
|
}
|
|
|
initData.start_time = new Date();
|
|
|
- const sys_count = await this.total(timeRangData, 'sys_count');
|
|
|
- const interface_exception_count = await this.total(timeRangData, 'interface_exception_count');
|
|
|
- const total = sys_count + interface_exception_count;
|
|
|
+ const obj = await this.total(timeRangData);
|
|
|
|
|
|
initData.end_time = new Date();
|
|
|
|
|
|
await ctx.service.statisticsService.save(ctx.model.Local.AppExceptionRecordModel,
|
|
|
- { ...initData, total, sys_count, interface_exception_count,
|
|
|
- }, isForceUpdate);
|
|
|
+ { ...initData, ...obj }, isForceUpdate);
|
|
|
}
|
|
|
|
|
|
- async total({ startTime, endTime }, vString) {
|
|
|
+ async total({ startTime, endTime }) {
|
|
|
const { ctx } = this;
|
|
|
const agg = [
|
|
|
{ $match: ctx.helper.getTimeRangMatch(startTime, endTime, 'create_time') },
|
|
|
{ $group: {
|
|
|
_id: null,
|
|
|
- count: { $sum: `$${vString}` },
|
|
|
+ sys_count: { $sum: '$sys_count' },
|
|
|
+ interface_exception_count: { $sum: '$interface_exception_count' },
|
|
|
},
|
|
|
},
|
|
|
];
|
|
|
const result = await ctx.model.AppExceptionRecordModel.aggregate(agg);
|
|
|
+ let sys_count = 0;
|
|
|
+ let interface_exception_count = 0;
|
|
|
+ let total = 0;
|
|
|
if (result && result.length > 0) {
|
|
|
- return result[0].count;
|
|
|
+ sys_count = result[0].sys_count;
|
|
|
+ interface_exception_count = result[0].interface_exception_count;
|
|
|
+ total = sys_count + interface_exception_count;
|
|
|
}
|
|
|
- return 0;
|
|
|
+ return { sys_count, interface_exception_count, total };
|
|
|
}
|
|
|
|
|
|
|