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);
|
const tomorrow = new Date(today);
|
||||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||||
|
|
||||||
|
const safe = async <T>(fn: () => Promise<T>, fallback: T): Promise<T> => { try { return await fn() } catch { return fallback } };
|
||||||
|
|
||||||
const [
|
const [
|
||||||
totalUsers,
|
totalUsers,
|
||||||
newUsersToday,
|
newUsersToday,
|
||||||
@ -21,24 +23,14 @@ export class AdminDashboardService {
|
|||||||
totalFiles,
|
totalFiles,
|
||||||
storageAgg,
|
storageAgg,
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
this.prisma.user.count({ where: { deletedAt: null } }),
|
safe(() => this.prisma.user.count({ where: { deletedAt: null } }), 0),
|
||||||
this.prisma.user.count({
|
safe(() => this.prisma.user.count({ where: { createdAt: { gte: today, lt: tomorrow }, deletedAt: null } }), 0),
|
||||||
where: { createdAt: { gte: today, lt: tomorrow }, deletedAt: null },
|
safe(() => this.prisma.dailyLearningActivity.count({ where: { activityDate: { gte: today, lt: tomorrow } } }), 0),
|
||||||
}),
|
safe(() => this.prisma.knowledgeBase.count({ where: { deletedAt: null } }), 0),
|
||||||
this.prisma.dailyLearningActivity.count({
|
safe(() => this.prisma.knowledgeBase.count({ where: { createdAt: { gte: today, lt: tomorrow }, deletedAt: null } }), 0),
|
||||||
where: { activityDate: { gte: today, lt: tomorrow } },
|
safe(() => this.prisma.aiUsageLog.count({ where: { createdAt: { gte: today, lt: tomorrow } } }), 0),
|
||||||
}),
|
safe(() => this.prisma.uploadedFile.count(), 0),
|
||||||
this.prisma.knowledgeBase.count({ where: { deletedAt: null } }),
|
safe(() => this.prisma.uploadedFile.aggregate({ _sum: { sizeBytes: true } }), { _sum: { sizeBytes: 0 } }),
|
||||||
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 },
|
|
||||||
}),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const userTrend = await this.getUserTrend(30);
|
const userTrend = await this.getUserTrend(30);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user