From 2235d0d33d6bf86ee2c559cda632ecfee6e6d0d2 Mon Sep 17 00:00:00 2001 From: Z8MB1E Date: Tue, 20 Oct 2026 00:15:50 -0400 Subject: [PATCH] fix(xp): floor XP total so displays never render a float The virtual profiles.progression.xp field summed awards, scoreboard kills, and minigame/contribution xpEarned buckets without flooring, so fractional values leaked into user-facing displays (e.g. 9,001.625 XP). Floor the total in the afterRead hook so every consumer receives an integer, and update the profile page to show the already-resolved xpLevel.xp instead of the raw value. --- src/app/(frontend)/profile/[username]/page.tsx | 4 ++-- src/collections/users/Profiles.ts | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app/(frontend)/profile/[username]/page.tsx b/src/app/(frontend)/profile/[username]/page.tsx index c00aac00..8c836204 100644 --- a/src/app/(frontend)/profile/[username]/page.tsx +++ b/src/app/(frontend)/profile/[username]/page.tsx @@ -502,7 +502,7 @@ export default async function ProfilePage({ params }: ProfilePageProps) { /> - {xp.toLocaleString()} XP + {xpLevel.xp.toLocaleString()} XP @@ -828,7 +828,7 @@ export default async function ProfilePage({ params }: ProfilePageProps) { {xpLevel.levelName} - {xp.toLocaleString()} + {xpLevel.xp.toLocaleString()} XP diff --git a/src/collections/users/Profiles.ts b/src/collections/users/Profiles.ts index 4016a797..cd76010a 100644 --- a/src/collections/users/Profiles.ts +++ b/src/collections/users/Profiles.ts @@ -219,7 +219,10 @@ export const Profiles: CollectionConfig = { // Contribution ledger: crowdsourced XP (granted entries only) xpAcc += contributionsXp; - return xpAcc; + // XP is integer-valued. Floor the summed total so every + // consumer (sidebar, profile page, dashboards) renders a whole + // number instead of a float such as 9,001.625. + return Math.floor(xpAcc); }, ], },