2022-08-28 06:38:35 +02:00
|
|
|
import prisma from 'lib/prisma';
|
2022-11-10 07:46:50 +01:00
|
|
|
import { getWebsite } from 'queries';
|
|
|
|
import cache from 'lib/cache';
|
2022-07-12 23:14:36 +02:00
|
|
|
|
2022-11-01 07:42:37 +01:00
|
|
|
export async function resetWebsite(id) {
|
2022-08-29 09:02:38 +02:00
|
|
|
const { client, transaction } = prisma;
|
2022-08-28 06:38:35 +02:00
|
|
|
|
2022-11-10 07:46:50 +01:00
|
|
|
const { revId } = await getWebsite({ id });
|
|
|
|
|
2022-08-29 09:02:38 +02:00
|
|
|
return transaction([
|
2022-11-10 07:46:50 +01:00
|
|
|
client.websiteEvent.deleteMany({
|
2022-11-08 20:55:02 +01:00
|
|
|
where: { websiteId: id },
|
2022-08-28 06:38:35 +02:00
|
|
|
}),
|
|
|
|
client.session.deleteMany({
|
2022-11-08 20:55:02 +01:00
|
|
|
where: { websiteId: id },
|
2022-08-28 06:38:35 +02:00
|
|
|
}),
|
2022-11-10 07:46:50 +01:00
|
|
|
client.website.update({ where: { id }, data: { revId: revId + 1 } }),
|
|
|
|
]).then(async data => {
|
|
|
|
if (cache.enabled) {
|
|
|
|
await cache.storeWebsite(data[2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
});
|
2022-07-12 23:14:36 +02:00
|
|
|
}
|