mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 15:17:23 +01:00
add db call as fallback
This commit is contained in:
parent
9ddbd12060
commit
b6cd9f305b
10 changed files with 71 additions and 40 deletions
|
|
@ -1,9 +1,12 @@
|
|||
import prisma from 'lib/prisma';
|
||||
import redis from 'lib/redis';
|
||||
import redis, { DELETED } from 'lib/redis';
|
||||
import { getWebsiteById } from 'queries';
|
||||
|
||||
export async function deleteWebsite(website_id) {
|
||||
const { client, transaction } = prisma;
|
||||
|
||||
const { website_uuid } = await getWebsiteById(website_id);
|
||||
|
||||
return transaction([
|
||||
client.pageview.deleteMany({
|
||||
where: { session: { website: { website_id } } },
|
||||
|
|
@ -21,8 +24,10 @@ export async function deleteWebsite(website_id) {
|
|||
where: { website_id },
|
||||
}),
|
||||
]).then(async res => {
|
||||
if (process.env.REDIS_URL) {
|
||||
await redis.client.del(`website:${res.website_uuid}`);
|
||||
if (redis.client) {
|
||||
await redis.client.set(`website:${website_uuid}`, DELETED);
|
||||
}
|
||||
|
||||
return res;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue