1
0
Fork 0

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.
This commit is contained in:
Jason Fraley 2026-10-20 00:15:50 -04:00
parent 72276b6741
commit 2235d0d33d
2 changed files with 6 additions and 3 deletions

View file

@ -502,7 +502,7 @@ export default async function ProfilePage({ params }: ProfilePageProps) {
/>
</div>
<span className="text-xs font-mono text-muted-foreground">
{xp.toLocaleString()} XP
{xpLevel.xp.toLocaleString()} XP
</span>
</div>
</div>
@ -828,7 +828,7 @@ export default async function ProfilePage({ params }: ProfilePageProps) {
<ItemTitle className="flex justify-between items-center w-full">
<span className="uppercase">{xpLevel.levelName}</span>
<span className="text-2xl font-bold font-mono">
{xp.toLocaleString()}
{xpLevel.xp.toLocaleString()}
<span className="text-xs text-muted-foreground font-normal ml-1">XP</span>
</span>
</ItemTitle>

View file

@ -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);
},
],
},