fix: alot
CI / build-and-test (push) Canceled after 0s

This commit is contained in:
2026-10-19 21:41:07 +02:00
parent df90cf8a18
commit fa38ac7617
70 changed files with 1389 additions and 1023 deletions
+7 -5
View File
@@ -1,5 +1,6 @@
import { Injectable } from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';
import { customerNameKey } from '../planned-tabs/customer-name';
@Injectable()
export class TabsService {
@@ -15,7 +16,7 @@ export class TabsService {
},
});
const snapshots = await this.prisma.openTabSnapshot.findMany({
const snapshots = ownerships.length === 0 ? [] : await this.prisma.openTabSnapshot.findMany({
where: {
OR: ownerships.map((o) => ({ deviceId: o.deviceId, tabId: o.tabId })),
},
@@ -25,15 +26,16 @@ export class TabsService {
// Customer details (email for reminders) live on the planned customer with the same name
const planned = await this.prisma.plannedTab.findMany({
where: { venueId },
select: { id: true, customerName: true, email: true },
select: { id: true, customerNameKey: true, email: true },
});
const plannedByName = new Map(planned.map((p) => [p.customerName, p]));
const plannedByKey = new Map(planned.map((p) => [p.customerNameKey, p]));
const tabs = [];
for (const ownership of ownerships) {
const snapshot = snapshotByKey.get(`${ownership.deviceId}:${ownership.tabId}`);
if (snapshot) {
const plannedTab = plannedByKey.get(customerNameKey(snapshot.customerName));
tabs.push({
tabId: snapshot.tabId,
customerName: snapshot.customerName,
@@ -47,8 +49,8 @@ export class TabsService {
deviceLastSeenAt: ownership.device.lastSeenAt,
deviceRevokedAt: ownership.device.revokedAt,
lastReportedAt: snapshot.reportedAt,
plannedTabId: plannedByName.get(snapshot.customerName)?.id ?? null,
email: plannedByName.get(snapshot.customerName)?.email ?? null,
plannedTabId: plannedTab?.id ?? null,
email: plannedTab?.email ?? null,
});
}
}