mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
api and lib fixes (#1643)
This commit is contained in:
parent
168283bf11
commit
13fd3ccd16
9 changed files with 30 additions and 29 deletions
|
|
@ -8,19 +8,25 @@ export async function deleteUser(userId) {
|
|||
where: { userId },
|
||||
});
|
||||
|
||||
let websiteIds = [];
|
||||
|
||||
if (websites.length > 0) {
|
||||
websiteIds = websites.map(a => a.id);
|
||||
}
|
||||
|
||||
return client
|
||||
.$transaction([
|
||||
client.pageview.deleteMany({
|
||||
where: { session: { website: { userId } } },
|
||||
where: { websiteId: { in: websiteIds } },
|
||||
}),
|
||||
client.eventData.deleteMany({
|
||||
where: { event: { session: { website: { userId } } } },
|
||||
where: { event: { websiteId: { in: websiteIds } } },
|
||||
}),
|
||||
client.event.deleteMany({
|
||||
where: { session: { website: { userId } } },
|
||||
where: { websiteId: { in: websiteIds } },
|
||||
}),
|
||||
client.session.deleteMany({
|
||||
where: { website: { userId } },
|
||||
where: { websiteId: { in: websiteIds } },
|
||||
}),
|
||||
client.website.deleteMany({
|
||||
where: { userId },
|
||||
|
|
|
|||
|
|
@ -6,16 +6,16 @@ export async function deleteWebsite(id) {
|
|||
|
||||
return transaction([
|
||||
client.pageview.deleteMany({
|
||||
where: { session: { website: { id } } },
|
||||
where: { websiteId: id },
|
||||
}),
|
||||
client.eventData.deleteMany({
|
||||
where: { event: { session: { website: { id } } } },
|
||||
where: { event: { websiteId: id } },
|
||||
}),
|
||||
client.event.deleteMany({
|
||||
where: { session: { website: { id } } },
|
||||
where: { websiteId: id },
|
||||
}),
|
||||
client.session.deleteMany({
|
||||
where: { website: { id } },
|
||||
where: { websiteId: id },
|
||||
}),
|
||||
client.website.delete({
|
||||
where: { id },
|
||||
|
|
|
|||
|
|
@ -5,16 +5,16 @@ export async function resetWebsite(id) {
|
|||
|
||||
return transaction([
|
||||
client.pageview.deleteMany({
|
||||
where: { session: { website: { id } } },
|
||||
where: { websiteId: id },
|
||||
}),
|
||||
client.eventData.deleteMany({
|
||||
where: { event: { session: { website: { id } } } },
|
||||
where: { event: { websiteId: id } },
|
||||
}),
|
||||
client.event.deleteMany({
|
||||
where: { session: { website: { id } } },
|
||||
where: { websiteId: id },
|
||||
}),
|
||||
client.session.deleteMany({
|
||||
where: { website: { id } },
|
||||
where: { websiteId: id },
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,10 +12,8 @@ export function getEvents(...args) {
|
|||
function relationalQuery(websites, start_at) {
|
||||
return prisma.client.event.findMany({
|
||||
where: {
|
||||
website: {
|
||||
id: {
|
||||
in: websites,
|
||||
},
|
||||
websiteId: {
|
||||
in: websites,
|
||||
},
|
||||
createdAt: {
|
||||
gte: start_at,
|
||||
|
|
|
|||
|
|
@ -12,10 +12,8 @@ export async function getPageviews(...args) {
|
|||
async function relationalQuery(websites, start_at) {
|
||||
return prisma.client.pageview.findMany({
|
||||
where: {
|
||||
website: {
|
||||
id: {
|
||||
in: websites,
|
||||
},
|
||||
websiteId: {
|
||||
in: websites,
|
||||
},
|
||||
createdAt: {
|
||||
gte: start_at,
|
||||
|
|
|
|||
|
|
@ -14,10 +14,8 @@ async function relationalQuery(websites, start_at) {
|
|||
where: {
|
||||
...(websites && websites.length > 0
|
||||
? {
|
||||
website: {
|
||||
id: {
|
||||
in: websites,
|
||||
},
|
||||
websiteId: {
|
||||
in: websites,
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue