From 77016a03c78e15e9b67dda1d64cc93d8d7e8a1c2 Mon Sep 17 00:00:00 2001
From: dmitriylaukhin
Date: Mon, 11 May 2026 18:52:40 +0500
Subject: [PATCH] Add active users last 24h card to admin dashboard
---
src/app/admin/dashboard/page.tsx | 15 +++++++++++++++
1 file changed, 15 insertions(+)
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}
+
уникальных пользователей
+