Add delete account function

This commit is contained in:
Hornwitser 2025-03-07 22:28:55 +01:00
parent 3535105744
commit 598b9fd7d6
5 changed files with 96 additions and 19 deletions

21
server/utils/schedule.ts Normal file
View file

@ -0,0 +1,21 @@
import { Account } from '~/shared/types/account';
import { readSchedule, writeSchedule } from '~/server/database';
import { broadcastUpdate } from '~/server/streams';
export async function updateScheduleInterestedCounts(accounts: Account[]) {
const counts = new Map();
for (const account of accounts)
if (account.interestedIds)
for (const id of account.interestedIds)
counts.set(id, (counts.get(id) ?? 0) + 1);
const schedule = await readSchedule();
for (const event of schedule.events) {
event.interested = counts.get(event.id);
for (const slot of event.slots) {
slot.interested = counts.get(slot.id);
}
}
await writeSchedule(schedule);
broadcastUpdate(schedule);
}