feat: add realtime
This commit is contained in:
@@ -22,6 +22,13 @@ export class TabsService {
|
||||
});
|
||||
const snapshotByKey = new Map(snapshots.map((s) => [`${s.deviceId}:${s.tabId}`, s]));
|
||||
|
||||
// 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 },
|
||||
});
|
||||
const plannedByName = new Map(planned.map((p) => [p.customerName, p]));
|
||||
|
||||
const tabs = [];
|
||||
for (const ownership of ownerships) {
|
||||
const snapshot = snapshotByKey.get(`${ownership.deviceId}:${ownership.tabId}`);
|
||||
@@ -38,6 +45,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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user