Add delete account function
This commit is contained in:
parent
3535105744
commit
598b9fd7d6
5 changed files with 96 additions and 19 deletions
|
@ -1,6 +1,5 @@
|
|||
import { Account } from "~/shared/types/account";
|
||||
import { readAccounts, readSchedule, writeAccounts, writeSchedule } from "~/server/database";
|
||||
import { broadcastUpdate } from "~/server/streams";
|
||||
import { readAccounts, writeAccounts } from "~/server/database";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const session = await requireAccountSession(event);
|
||||
|
@ -28,19 +27,6 @@ export default defineEventHandler(async (event) => {
|
|||
}
|
||||
await writeAccounts(accounts);
|
||||
|
||||
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);
|
||||
// Update Schedule counts.
|
||||
await updateScheduleInterestedCounts(accounts);
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue