import { prisma } from './prisma'; export class AnalyticsService { static async getDashboardStats(organizationId: string) { const [totalUsers, activeEnrollments, completedEnrollments, totalTracks, totalRevenue] = await Promise.all([ prisma.user.count({ where: { organizationId, deletedAt: null } }), prisma.enrollment.count({ where: { status: 'ACTIVE', organizationId, deletedAt: null } }), prisma.enrollment.count({ where: { status: 'COMPLETED', organizationId, deletedAt: null } }), prisma.track.count({ where: { organizationId } }), prisma.payment.aggregate({ where: { status: 'COMPLETED', organizationId }, _sum: { amount: true } }), ]); return { totalUsers, activeEnrollments, completedEnrollments, totalTracks, totalRevenue: totalRevenue._sum.amount || 0 }; } }