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)),
|
value: parseInt(String(item.value)),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const userCount = await db
|
const userCount =
|
||||||
.selectFrom("users")
|
(
|
||||||
.select((eb) => [eb.fn.count<number>("id").as("count")])
|
await db
|
||||||
.executeTakeFirstOrThrow();
|
.selectFrom("users")
|
||||||
|
.select((eb) => [eb.fn.count<number>("id").as("count")])
|
||||||
|
.executeTakeFirst()
|
||||||
|
)?.count || 0;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
userTimeserie,
|
userTimeserie,
|
||||||
userCount: userCount.count,
|
userCount,
|
||||||
contattiTimeserie,
|
contattiTimeserie,
|
||||||
serviziTimeserie,
|
serviziTimeserie,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue