fix: hide deleted signatures and fit uplink table
This commit is contained in:
@@ -142,6 +142,19 @@ describe('SignatureRetirementService dimensions', () => {
|
||||
page: 2,
|
||||
pageSize: 10,
|
||||
});
|
||||
const query = prisma.$queryRaw.mock.calls[0]?.[0] as { strings?: readonly string[] };
|
||||
expect(query.strings?.join('?')).toContain('signature."auditStatus" <> \'deleted\'');
|
||||
});
|
||||
|
||||
it('does not count deleted signatures as unread retirement warnings', async () => {
|
||||
const prisma = { $queryRaw: jest.fn().mockResolvedValue([{ count: 2 }]) };
|
||||
const unreadService = new SignatureRetirementService(prisma as never);
|
||||
|
||||
await expect(unreadService.unreadCount()).resolves.toEqual({ count: 2 });
|
||||
const query = prisma.$queryRaw.mock.calls[0]?.[0] as { strings?: readonly string[] };
|
||||
const sql = query.strings?.join('?') ?? '';
|
||||
expect(sql).toContain('JOIN "SmsSignature" signature ON signature.id = detection."signatureId"');
|
||||
expect(sql).toContain('signature."auditStatus" <> \'deleted\'');
|
||||
});
|
||||
|
||||
it('requires a reason for temporary and permanent suppression', async () => {
|
||||
|
||||
@@ -128,6 +128,7 @@ export class SignatureRetirementService implements OnModuleInit, OnModuleDestroy
|
||||
LEFT JOIN "SmsApplication" application ON application.id = detection."applicationId"
|
||||
WHERE message."createdAt" >= ${range?.gte}
|
||||
AND message."createdAt" <= ${range?.lte}
|
||||
AND signature."auditStatus" <> 'deleted'
|
||||
AND (${dimensionType}::text IS NULL OR detection."dimensionType" = ${dimensionType})
|
||||
AND (${tenantId}::text IS NULL OR detection."tenantId" = ${tenantId})
|
||||
AND (${applicationId}::text IS NULL OR application.id = ${applicationId})
|
||||
@@ -167,8 +168,18 @@ export class SignatureRetirementService implements OnModuleInit, OnModuleDestroy
|
||||
|
||||
async unreadCount() {
|
||||
const range = shanghaiDateRange(shanghaiDateKey(), shanghaiDateKey());
|
||||
const count = await this.prisma.signatureRetirementMessage.count({ where: { createdAt: range, isRead: false, suppressed: false } });
|
||||
return { count };
|
||||
const rows = await this.prisma.$queryRaw<Array<{ count: number }>>(Prisma.sql`
|
||||
SELECT COUNT(*)::integer AS count
|
||||
FROM "SignatureRetirementMessage" message
|
||||
JOIN "SignatureRetirementDetection" detection ON detection.id = message."detectionId"
|
||||
JOIN "SmsSignature" signature ON signature.id = detection."signatureId"
|
||||
WHERE message."createdAt" >= ${range?.gte}
|
||||
AND message."createdAt" <= ${range?.lte}
|
||||
AND message."isRead" = FALSE
|
||||
AND message.suppressed = FALSE
|
||||
AND signature."auditStatus" <> 'deleted'
|
||||
`);
|
||||
return { count: rows[0]?.count ?? 0 };
|
||||
}
|
||||
|
||||
async markRead(id: string) {
|
||||
|
||||
Reference in New Issue
Block a user