update schema and queries to implement reset_at

This commit is contained in:
Francis Cao 2023-03-27 11:25:16 -07:00
parent 43ef6884df
commit 14e4a090bb
15 changed files with 74 additions and 59 deletions

View file

@ -49,8 +49,6 @@ export async function resetWebsite(
): Promise<[Prisma.BatchPayload, Prisma.BatchPayload, Website]> {
const { client, transaction } = prisma;
const { revId } = await getWebsite({ id: websiteId });
return transaction([
client.websiteEvent.deleteMany({
where: { websiteId },
@ -58,7 +56,12 @@ export async function resetWebsite(
client.session.deleteMany({
where: { websiteId },
}),
client.website.update({ where: { id: websiteId }, data: { revId: revId + 1 } }),
client.website.update({
where: { id: websiteId },
data: {
resetAt: new Date(),
},
}),
]).then(async data => {
if (cache.enabled) {
await cache.storeWebsite(data[2]);