Fix user count retrieval in stats router to handle potential null values

This commit is contained in:
Marco Pedone 2025-08-06 09:17:51 +02:00
parent c426566cca
commit 77f1bec4ce

View file

@ -76,14 +76,17 @@ export const statsRouter = createTRPCRouter({
value: parseInt(String(item.value)),
}));
const userCount = await db
const userCount =
(
await db
.selectFrom("users")
.select((eb) => [eb.fn.count<number>("id").as("count")])
.executeTakeFirstOrThrow();
.executeTakeFirst()
)?.count || 0;
return {
userTimeserie,
userCount: userCount.count,
userCount,
contattiTimeserie,
serviziTimeserie,
};