This commit is contained in:
2026-09-19 22:19:35 +02:00
commit 231b3e006a
124 changed files with 13816 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
import { Injectable } from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';
@Injectable()
export class TabsService {
constructor(private prisma: PrismaService) {}
async findAll(venueId: string) {
const ownerships = await this.prisma.tabOwnership.findMany({
where: { venueId },
include: {
device: {
select: { id: true, name: true, lastSeenAt: true, revokedAt: true },
},
},
});
const tabs = [];
for (const ownership of ownerships) {
const snapshot = await this.prisma.openTabSnapshot.findFirst({
where: { tabId: ownership.tabId, deviceId: ownership.deviceId },
orderBy: { reportedAt: 'desc' },
});
if (snapshot) {
tabs.push({
tabId: snapshot.tabId,
customerName: snapshot.customerName,
version: snapshot.version,
totalInCents: snapshot.totalInCents,
itemCount: snapshot.itemCount,
deviceId: ownership.device.id,
deviceName: ownership.device.name,
deviceLastSeenAt: ownership.device.lastSeenAt,
deviceRevokedAt: ownership.device.revokedAt,
lastReportedAt: snapshot.reportedAt,
});
}
}
return { tabs };
}
}