import { adminProcedure, createTRPCRouter } from "~/server/api/trpc";
import { db } from "~/server/db";

export const statsRouter = createTRPCRouter({
	adminDashStats: adminProcedure.query(async () => {
		const userCount =
			(
				await db
					.selectFrom("users")
					.select((eb) => [eb.fn.count<number>("id").as("count")])
					.executeTakeFirst()
			)?.count || 0;

		return {
			userCount,
		};
	}),
});
