feat: optimize signature workflows and high-frequency queries

This commit is contained in:
hectorzhao
2026-09-02 15:45:48 +08:00
parent 9b8196ecab
commit ad89e8fed7
48 changed files with 1334 additions and 352 deletions
+5
View File
@@ -18,6 +18,11 @@ export class TenantsController {
return this.tenants.listManagementRows();
}
@Get('options')
listOptions() {
return this.tenants.listOptions();
}
@Get(':id')
get(@Param('id') id: string) {
return this.tenants.get(id);
+13
View File
@@ -44,6 +44,19 @@ function createPrismaMock() {
}
describe('TenantsService', () => {
it('returns lightweight non-deleted tenant options', async () => {
const prisma = createPrismaMock();
const service = new TenantsService(prisma as never);
await service.listOptions();
expect(prisma.tenant.findMany).toHaveBeenCalledWith({
where: { status: { not: 'deleted' } },
select: { id: true, name: true, code: true, status: true },
orderBy: [{ name: 'asc' }, { id: 'asc' }],
});
});
it('creates tenants with a real enterprise profile', async () => {
const prisma = createPrismaMock();
const service = new TenantsService(prisma as never);
+8
View File
@@ -44,6 +44,14 @@ export class TenantsService {
}).then((items) => items.map(withEnterpriseProfile));
}
listOptions() {
return this.prisma.tenant.findMany({
where: { status: { not: 'deleted' } },
select: { id: true, name: true, code: true, status: true },
orderBy: [{ name: 'asc' }, { id: 'asc' }],
});
}
async listManagementRows() {
const sinceToday = startOfToday();
const [tenants, accounts, todaySpendGroups, todayRefundGroups] = await Promise.all([