pnpm build

This commit is contained in:
UltraLionFr
2025-08-20 17:14:23 +02:00
parent 9730e21999
commit 673119679e
8 changed files with 56 additions and 53 deletions
+25 -24
View File
@@ -1,27 +1,28 @@
import { prisma } from '@/lib/prisma';
import { prisma } from "@/lib/prisma";
export async function getDashboardStats(userId?: string) {
const filter = userId ? { where: { createdBy: userId } } : {};
const where = userId ? { createdBy: userId } : undefined;
const [totalPastes, totalViews, recentPastes, apiUsage, storageUsed, avgViews, mostViewed, avgSize] = await Promise.all([
prisma.paste.count(filter),
prisma.paste.aggregate({ _sum: { views: true }, ...filter }),
prisma.paste.count({
where: {
createdAt: { gte: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000) },
...(userId ? { createdBy: userId } : {}),
},
}),
prisma.paste.count({ where: { createdBy: { not: null } } }),
prisma.paste.aggregate({ _sum: { size: true }, ...filter }),
prisma.paste.aggregate({ _avg: { views: true }, ...filter }),
prisma.paste.findFirst({
orderBy: { views: 'desc' },
select: { views: true },
...(userId ? { where: { createdBy: userId } } : {}),
}),
prisma.paste.aggregate({ _avg: { size: true }, ...filter }),
]);
const [totalPastes, totalViews, recentPastes, apiUsage, storageUsed, avgViews, mostViewed, avgSize] =
await Promise.all([
prisma.paste.count({ where }),
prisma.paste.aggregate({ _sum: { views: true }, where }),
prisma.paste.count({
where: {
createdAt: { gte: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000) },
...(userId ? { createdBy: userId } : {}),
},
}),
prisma.paste.count({ where: { createdBy: { not: null } } }),
prisma.paste.aggregate({ _sum: { size: true }, where }),
prisma.paste.aggregate({ _avg: { views: true }, where }),
prisma.paste.findFirst({
orderBy: { views: "desc" },
select: { views: true },
where,
}),
prisma.paste.aggregate({ _avg: { size: true }, where }),
]);
return {
totalPastes,
@@ -36,9 +37,9 @@ export async function getDashboardStats(userId?: string) {
}
export async function getUserPastes(userId: string) {
return await prisma.paste.findMany({
return prisma.paste.findMany({
where: { createdBy: userId },
orderBy: { createdAt: 'desc' },
orderBy: { createdAt: "desc" },
select: {
id: true,
createdAt: true,
@@ -47,4 +48,4 @@ export async function getUserPastes(userId: string) {
content: true,
},
});
}
}