Skip to content

Commit a13e656

Browse files
committed
fix: store full precision for total hours played
Remove rounding to 2 decimals in UpdatePlaytimeUseCase when updating TotalHoursPlayed. Reasons: - Avoid loss of precision for accumulated playtime. - Ensure backend stores the most accurate value, allowing the client to display or round as needed. - Prevent potential floating-point errors from repeated small increments. - Keep total hours played more consistent and reliable for reporting or analytics.
1 parent 0f826bd commit a13e656

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

src/UseCases/Testers/UpdatePlaytime.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ public async Task<Result> ExecuteAsync(string accessKey, UpdatePlaytimeRequest r
2828
if (validationResult.IsFailed())
2929
return validationResult.Invalid();
3030

31-
double roundedHours = Math.Round(request.HoursPlayed, 2);
3231
int affectedRows = await dbContext
3332
.Set<Tester>()
3433
.Where(t => t.AccessKey == accessKey)
3534
.ExecuteUpdateAsync(setters => setters
36-
.SetProperty(t => t.TotalHoursPlayed, t => t.TotalHoursPlayed + roundedHours));
35+
.SetProperty(t => t.TotalHoursPlayed, t => t.TotalHoursPlayed + request.HoursPlayed));
3736

3837
return affectedRows == 0 ? Result.NotFound() : Result.Success();
3938
}

0 commit comments

Comments
 (0)