From 6648d9e593b07fb415f13480bbf0eb8dc438057e Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Sat, 4 Oct 2025 15:53:25 +0200 Subject: [PATCH] Fix stats endpoint returning null for totalPointsTracked --- CHANGELOG.md | 6 ++++++ app/serializers/stats_serializer.rb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9a41d89..36525e9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +# [UNRELEASED] + +## Fixed + +- `GET /api/v1/stats` endpoint now returns correct 0 instead of null if no points were tracked in the requested period. + # [0.33.0] - 2025-09-29 ## Fixed diff --git a/app/serializers/stats_serializer.rb b/app/serializers/stats_serializer.rb index ae66afbf..bd3939fb 100644 --- a/app/serializers/stats_serializer.rb +++ b/app/serializers/stats_serializer.rb @@ -10,7 +10,7 @@ class StatsSerializer def call { totalDistanceKm: total_distance_km, - totalPointsTracked: user.points_count, + totalPointsTracked: user.points_count.to_i, totalReverseGeocodedPoints: reverse_geocoded_points, totalCountriesVisited: user.countries_visited.count, totalCitiesVisited: user.cities_visited.count,