fix: dashboard safe queries for missing tables + workflow prisma generate
Some checks failed
Deploy API Server / build-and-deploy (push) Has been cancelled
Some checks failed
Deploy API Server / build-and-deploy (push) Has been cancelled
This commit is contained in:
parent
fd1897d385
commit
6aa24cc5bb
@ -11,6 +11,8 @@ export class AdminDashboardService {
|
||||
const tomorrow = new Date(today);
|
||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||
|
||||
const safe = async <T>(fn: () => Promise<T>, fallback: T): Promise<T> => { try { return await fn() } catch { return fallback } };
|
||||
|
||||
const [
|
||||
totalUsers,
|
||||
newUsersToday,
|
||||
@ -21,24 +23,14 @@ export class AdminDashboardService {
|
||||
totalFiles,
|
||||
storageAgg,
|
||||
] = await Promise.all([
|
||||
this.prisma.user.count({ where: { deletedAt: null } }),
|
||||
this.prisma.user.count({
|
||||
where: { createdAt: { gte: today, lt: tomorrow }, deletedAt: null },
|
||||
}),
|
||||
this.prisma.dailyLearningActivity.count({
|
||||
where: { activityDate: { gte: today, lt: tomorrow } },
|
||||
}),
|
||||
this.prisma.knowledgeBase.count({ where: { deletedAt: null } }),
|
||||
this.prisma.knowledgeBase.count({
|
||||
where: { createdAt: { gte: today, lt: tomorrow }, deletedAt: null },
|
||||
}),
|
||||
this.prisma.aiUsageLog.count({
|
||||
where: { createdAt: { gte: today, lt: tomorrow } },
|
||||
}),
|
||||
this.prisma.uploadedFile.count(),
|
||||
this.prisma.uploadedFile.aggregate({
|
||||
_sum: { sizeBytes: true },
|
||||
}),
|
||||
safe(() => this.prisma.user.count({ where: { deletedAt: null } }), 0),
|
||||
safe(() => this.prisma.user.count({ where: { createdAt: { gte: today, lt: tomorrow }, deletedAt: null } }), 0),
|
||||
safe(() => this.prisma.dailyLearningActivity.count({ where: { activityDate: { gte: today, lt: tomorrow } } }), 0),
|
||||
safe(() => this.prisma.knowledgeBase.count({ where: { deletedAt: null } }), 0),
|
||||
safe(() => this.prisma.knowledgeBase.count({ where: { createdAt: { gte: today, lt: tomorrow }, deletedAt: null } }), 0),
|
||||
safe(() => this.prisma.aiUsageLog.count({ where: { createdAt: { gte: today, lt: tomorrow } } }), 0),
|
||||
safe(() => this.prisma.uploadedFile.count(), 0),
|
||||
safe(() => this.prisma.uploadedFile.aggregate({ _sum: { sizeBytes: true } }), { _sum: { sizeBytes: 0 } }),
|
||||
]);
|
||||
|
||||
const userTrend = await this.getUserTrend(30);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user