feat: optimize signature workflows and high-frequency queries
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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([
|
||||
|
||||
Reference in New Issue
Block a user