Switch calendar events to isArchived model

This commit is contained in:
Ruslan Bakiev
2026-02-19 16:58:49 +07:00
parent 1047d5cb3f
commit f6fd11b3c4
9 changed files with 306 additions and 118 deletions

View File

@@ -9,7 +9,9 @@ type CalendarSnapshotRow = {
startsAt: string;
endsAt: string | null;
note: string | null;
status: string | null;
isArchived: boolean;
archiveNote: string | null;
archivedAt: string | null;
};
type ContactNoteSnapshotRow = {
@@ -101,7 +103,9 @@ export async function captureSnapshot(prisma: PrismaClient, teamId: string): Pro
startsAt: true,
endsAt: true,
note: true,
status: true,
isArchived: true,
archiveNote: true,
archivedAt: true,
},
take: 4000,
}),
@@ -135,7 +139,9 @@ export async function captureSnapshot(prisma: PrismaClient, teamId: string): Pro
startsAt: row.startsAt.toISOString(),
endsAt: row.endsAt?.toISOString() ?? null,
note: row.note ?? null,
status: row.status ?? null,
isArchived: Boolean(row.isArchived),
archiveNote: row.archiveNote ?? null,
archivedAt: row.archivedAt?.toISOString() ?? null,
},
]),
),
@@ -203,7 +209,9 @@ export function buildChangeSet(before: SnapshotState, after: SnapshotState): Cha
prev.startsAt !== row.startsAt ||
prev.endsAt !== row.endsAt ||
fmt(prev.note) !== fmt(row.note) ||
fmt(prev.status) !== fmt(row.status) ||
prev.isArchived !== row.isArchived ||
fmt(prev.archiveNote) !== fmt(row.archiveNote) ||
fmt(prev.archivedAt) !== fmt(row.archivedAt) ||
prev.contactId !== row.contactId
) {
items.push({
@@ -336,7 +344,9 @@ export async function rollbackChangeSet(prisma: PrismaClient, teamId: string, ch
startsAt: new Date(row.startsAt),
endsAt: row.endsAt ? new Date(row.endsAt) : null,
note: row.note,
status: row.status,
isArchived: row.isArchived,
archiveNote: row.archiveNote,
archivedAt: row.archivedAt ? new Date(row.archivedAt) : null,
},
create: {
id: row.id,
@@ -346,7 +356,9 @@ export async function rollbackChangeSet(prisma: PrismaClient, teamId: string, ch
startsAt: new Date(row.startsAt),
endsAt: row.endsAt ? new Date(row.endsAt) : null,
note: row.note,
status: row.status,
isArchived: row.isArchived,
archiveNote: row.archiveNote,
archivedAt: row.archivedAt ? new Date(row.archivedAt) : null,
},
});
continue;
@@ -412,4 +424,3 @@ export async function rollbackChangeSet(prisma: PrismaClient, teamId: string, ch
}
});
}