diff --git a/src/app/admin/dashboard/page.tsx b/src/app/admin/dashboard/page.tsx index 3b34ef3..9e10851 100644 --- a/src/app/admin/dashboard/page.tsx +++ b/src/app/admin/dashboard/page.tsx @@ -3,6 +3,7 @@ import Link from "next/link"; export default async function AdminDashboard() { const now = new Date(); + const dayAgo = new Date(now.getTime() - 24 * 60 * 60 * 1000); const weekAgo = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000); const monthAgo = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000); @@ -17,6 +18,7 @@ export default async function AdminDashboard() { homeworkTotal, progressTotal, balanceAggregate, + activeLast24h, ] = await Promise.all([ prisma.user.count({ where: { role: "student" } }), prisma.user.count({ where: { role: "student", createdAt: { gte: monthAgo } } }), @@ -32,6 +34,11 @@ export default async function AdminDashboard() { prisma.homeworkSubmission.count(), prisma.lessonProgress.count(), prisma.balanceTransaction.aggregate({ _sum: { amount: true } }), + prisma.session.findMany({ + where: { createdAt: { gte: dayAgo } }, + select: { userId: true }, + distinct: ["userId"], + }).then((rows) => rows.length), ]); const totalBalance = Number(balanceAggregate._sum.amount ?? 0); @@ -179,6 +186,14 @@ export default async function AdminDashboard() {
сумма по всем пользователям
+ ++ Авторизации за 24 часа +
+{activeLast24h}
+уникальных пользователей
+