2022-08-28 06:38:35 +02:00
|
|
|
import prisma from 'lib/prisma';
|
|
|
|
import redis from 'lib/redis';
|
2022-07-12 23:14:36 +02:00
|
|
|
|
|
|
|
export async function resetWebsite(website_id) {
|
2022-08-28 06:38:35 +02:00
|
|
|
const { client, multiQuery } = prisma;
|
|
|
|
|
|
|
|
return multiQuery([
|
|
|
|
client.pageview.deleteMany({
|
|
|
|
where: { session: { website: { website_id } } },
|
|
|
|
}),
|
|
|
|
client.event_data.deleteMany({
|
|
|
|
where: { event: { session: { website: { website_id } } } },
|
|
|
|
}),
|
|
|
|
client.event.deleteMany({
|
|
|
|
where: { session: { website: { website_id } } },
|
|
|
|
}),
|
|
|
|
client.session.deleteMany({
|
|
|
|
where: { website: { website_id } },
|
|
|
|
}),
|
|
|
|
]).then(async res => {
|
|
|
|
if (process.env.REDIS_URL) {
|
|
|
|
await redis.del(`website:${res.website_uuid}`);
|
|
|
|
}
|
|
|
|
});
|
2022-07-12 23:14:36 +02:00
|
|
|
}
|