Skip to content

Commit 3ea6936

Browse files
prazgaitisclaude
andauthored
Round score to two decimal places in strava notification messages (#238)
https://claude.ai/code/session_01XwvSBeSRKUBieqeXhYi54U Co-authored-by: Claude <noreply@anthropic.com>
1 parent 47170f9 commit 3ea6936

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

apps/web/app/challenges/[id]/(dashboard)/notifications/notifications-list.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export function getNotificationMessage(notification: Notification) {
143143
const activityName = notification.data?.activityName as string | undefined;
144144
const points = notification.data?.pointsEarned as number | undefined;
145145
if (activityName && points != null) {
146-
return `Strava activity "${activityName}" imported — ${points} pts earned`;
146+
return `Strava activity "${activityName}" imported — ${parseFloat(points.toFixed(2))} pts earned`;
147147
}
148148
return "Your Strava activity was imported";
149149
}
@@ -155,10 +155,10 @@ export function getNotificationMessage(notification: Notification) {
155155
const label = activityName ? `"${activityName}"` : "Your activity";
156156
const mediaSuffix = hasNewMedia ? " with photos" : "";
157157
if (points != null && prevPoints != null && prevPoints !== points) {
158-
return `Strava activity ${label} updated${mediaSuffix}${points} pts (was ${prevPoints})`;
158+
return `Strava activity ${label} updated${mediaSuffix}${parseFloat(points.toFixed(2))} pts (was ${parseFloat(prevPoints.toFixed(2))})`;
159159
}
160160
if (points != null) {
161-
return `Strava activity ${label} updated${mediaSuffix}${points} pts`;
161+
return `Strava activity ${label} updated${mediaSuffix}${parseFloat(points.toFixed(2))} pts`;
162162
}
163163
return `Your Strava activity was updated${mediaSuffix}`;
164164
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Round Score to Two Decimal Places in Strava Notifications
2+
3+
**Date:** 2026-03-21
4+
5+
## Description
6+
7+
Round the `pointsEarned` score to two decimal places when displaying in Strava activity imported/updated notifications.
8+
9+
## Changes
10+
11+
- [x] Round `pointsEarned` to 2 decimal places in `strava_import` notification message
12+
- [x] Round `pointsEarned` to 2 decimal places in `strava_update` notification message
13+
- [x] Round `previousPointsEarned` to 2 decimal places in `strava_update` notification message (when showing "was X")
14+
15+
## Implementation Notes
16+
17+
- Used `parseFloat(points.toFixed(2))` to round to 2 decimal places while stripping trailing zeros (e.g., `10.00` becomes `10`, `10.50` becomes `10.5`)
18+
- Changes made in `apps/web/app/challenges/[id]/(dashboard)/notifications/notifications-list.tsx`

0 commit comments

Comments
 (0)