Fix user count retrieval in stats router to handle potential null values
This commit is contained in:
parent
c426566cca
commit
77f1bec4ce
1 changed files with 8 additions and 5 deletions
|
|
@ -76,14 +76,17 @@ export const statsRouter = createTRPCRouter({
|
|||
value: parseInt(String(item.value)),
|
||||
}));
|
||||
|
||||
const userCount = await db
|
||||
.selectFrom("users")
|
||||
.select((eb) => [eb.fn.count<number>("id").as("count")])
|
||||
.executeTakeFirstOrThrow();
|
||||
const userCount =
|
||||
(
|
||||
await db
|
||||
.selectFrom("users")
|
||||
.select((eb) => [eb.fn.count<number>("id").as("count")])
|
||||
.executeTakeFirst()
|
||||
)?.count || 0;
|
||||
|
||||
return {
|
||||
userTimeserie,
|
||||
userCount: userCount.count,
|
||||
userCount,
|
||||
contattiTimeserie,
|
||||
serviziTimeserie,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue