diff --git a/backend/src/routes/leaderboard.ts b/backend/src/routes/leaderboard.ts index 1af2de3..01e1b59 100644 --- a/backend/src/routes/leaderboard.ts +++ b/backend/src/routes/leaderboard.ts @@ -101,24 +101,22 @@ router.get('/me', async (req: Request, res: Response): Promise => { const evaluatedCount = parseInt(tipsStats?.count ?? '0'); const wrongCount = parseInt(tipsStats?.wrong_count ?? '0'); + const exactCount = parseInt(String(lb?.exact_count ?? '0')); + const tendencyCount = parseInt(String(lb?.tendency_count ?? '0')); const accuracy = evaluatedCount > 0 - ? Math.round( - (((lb?.exact_count ?? 0) + (lb?.tendency_count ?? 0)) / - evaluatedCount) * - 100 - ) + ? Math.round(((exactCount + tendencyCount) / evaluatedCount) * 100) : 0; const response: UserStatsResponse = { userId, fullName: lb?.full_name ?? req.staffbaseUser!.name ?? 'Unbekannt', team: lb?.team ?? null, - totalPoints: lb?.total_points ?? 0, - rank: lb?.rank ?? null, - tipsCount: lb?.tips_count ?? 0, - exactCount: lb?.exact_count ?? 0, - tendencyCount: lb?.tendency_count ?? 0, + totalPoints: parseInt(String(lb?.total_points ?? '0')), + rank: lb?.rank ? parseInt(String(lb.rank)) : null, + tipsCount: parseInt(String(lb?.tips_count ?? '0')), + exactCount, + tendencyCount, wrongCount, accuracy, };