feat: add signature quality period trends

This commit is contained in:
hectorzhao
2026-08-09 22:54:32 +08:00
parent 608662a054
commit 35de17a2d4
11 changed files with 385 additions and 30 deletions
+21 -3
View File
@@ -677,6 +677,7 @@ describe('OperationsService', () => {
averageArrivalMs: 1200,
rowCount: 12,
}])
.mockResolvedValueOnce([{ count: 4 }])
.mockResolvedValueOnce([
{
signatureId: 'signature-1',
@@ -727,6 +728,18 @@ describe('OperationsService', () => {
averageArrivalMs: 1800,
},
]);
prisma.$queryRaw.mockResolvedValueOnce([
{
signatureId: 'signature-1',
channelId: 'channel-1',
channelName: '通道一',
carrier: 'mobile',
date: '2026-07-24',
businessMessageCount: 3,
deliveredMessageCount: 2,
deliveryRate: 66.7,
},
]);
const service = new OperationsService(prisma as never);
await expect(service.signatureQuality({
@@ -736,6 +749,7 @@ describe('OperationsService', () => {
pageSize: 5,
})).resolves.toEqual({
date: '2026-07-24',
selectedDaySignatureCount: 4,
items: [expect.objectContaining({
signatureId: 'signature-1',
signatureName: '【测试签名】',
@@ -763,27 +777,31 @@ describe('OperationsService', () => {
expect.objectContaining({ channelId: 'channel-1', carrier: 'mobile', drainageState: 'with', total: 4 }),
expect.objectContaining({ channelId: 'channel-2', carrier: 'telecom', drainageState: 'without', total: 2 }),
],
dailyBreakdowns: [
expect.objectContaining({ channelId: 'channel-1', carrier: 'mobile', date: '2026-07-24', businessMessageCount: 3 }),
],
})],
total: 12,
page: 2,
pageSize: 5,
});
expect(prisma.$queryRaw).toHaveBeenCalledTimes(3);
expect(prisma.$queryRaw).toHaveBeenCalledTimes(5);
});
it('does not query channel details when the selected date has no registered signatures', async () => {
const prisma = createPrismaMock();
prisma.$queryRaw.mockResolvedValueOnce([]);
prisma.$queryRaw.mockResolvedValueOnce([]).mockResolvedValueOnce([{ count: 0 }]);
const service = new OperationsService(prisma as never);
await expect(service.signatureQuality({ date: '2026-07-24' })).resolves.toEqual({
date: '2026-07-24',
selectedDaySignatureCount: 0,
items: [],
total: 0,
page: 1,
pageSize: 10,
});
expect(prisma.$queryRaw).toHaveBeenCalledTimes(1);
expect(prisma.$queryRaw).toHaveBeenCalledTimes(2);
});
it('returns trace details and reconciliation diffs', async () => {