mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 13:47:15 +01:00
Added report context. Removed report store.
This commit is contained in:
parent
bc37f5124e
commit
bfb52eb678
31 changed files with 372 additions and 273 deletions
33
queries/admin/report.ts
Normal file
33
queries/admin/report.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { Prisma, Report } from '@prisma/client';
|
||||
import prisma from 'lib/prisma';
|
||||
|
||||
export async function createReport(data: Prisma.ReportUncheckedCreateInput): Promise<Report> {
|
||||
return prisma.client.report.create({ data });
|
||||
}
|
||||
|
||||
export async function getReportById(reportId: string): Promise<Report> {
|
||||
return prisma.client.report.findUnique({
|
||||
where: {
|
||||
id: reportId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getReports(userId: string): Promise<Report[]> {
|
||||
return prisma.client.report.findMany({
|
||||
where: {
|
||||
userId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function updateReport(
|
||||
data: Prisma.ReportUpdateInput,
|
||||
where: Prisma.ReportWhereUniqueInput,
|
||||
): Promise<Report> {
|
||||
return prisma.client.report.update({ data, where });
|
||||
}
|
||||
|
||||
export async function deleteReport(where: Prisma.ReportWhereUniqueInput): Promise<Report> {
|
||||
return prisma.client.report.delete({ where });
|
||||
}
|
||||
|
|
@ -210,7 +210,7 @@ export async function deleteUser(
|
|||
},
|
||||
},
|
||||
}),
|
||||
client.userReport.deleteMany({
|
||||
client.report.deleteMany({
|
||||
where: {
|
||||
OR: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
import { Prisma, UserReport } from '@prisma/client';
|
||||
import prisma from 'lib/prisma';
|
||||
|
||||
export async function createUserReport(
|
||||
data: Prisma.UserReportUncheckedCreateInput,
|
||||
): Promise<UserReport> {
|
||||
return prisma.client.userReport.create({ data });
|
||||
}
|
||||
|
||||
export async function getUserReportById(userReportId: string): Promise<UserReport> {
|
||||
return prisma.client.userReport.findUnique({
|
||||
where: {
|
||||
id: userReportId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function getUserReports(userId: string): Promise<UserReport[]> {
|
||||
return prisma.client.userReport.findMany({
|
||||
where: {
|
||||
userId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export async function updateUserReport(
|
||||
data: Prisma.UserReportUpdateInput,
|
||||
where: Prisma.UserReportWhereUniqueInput,
|
||||
): Promise<UserReport> {
|
||||
return prisma.client.userReport.update({ data, where });
|
||||
}
|
||||
|
||||
export async function deleteUserReport(
|
||||
where: Prisma.UserReportWhereUniqueInput,
|
||||
): Promise<UserReport> {
|
||||
return prisma.client.userReport.delete({ where });
|
||||
}
|
||||
|
|
@ -92,7 +92,7 @@ export async function deleteWebsite(
|
|||
websiteId,
|
||||
},
|
||||
}),
|
||||
client.userReport.deleteMany({
|
||||
client.report.deleteMany({
|
||||
where: {
|
||||
websiteId,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue