From 25b74716ee0acb80ad823831d31a78f49bc6caf7 Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Sun, 27 Jul 2025 20:14:36 +0200 Subject: [PATCH] Fix chart --- app/services/reverse_geocoding/places/fetch_data.rb | 6 +++--- app/views/stats/_year.html.erb | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/services/reverse_geocoding/places/fetch_data.rb b/app/services/reverse_geocoding/places/fetch_data.rb index 9f1551c5..240ac6de 100644 --- a/app/services/reverse_geocoding/places/fetch_data.rb +++ b/app/services/reverse_geocoding/places/fetch_data.rb @@ -112,13 +112,13 @@ class ReverseGeocoding::Places::FetchData place.country = data['properties']['country'] place.geodata = data place.source = :photon - if place.lonlat.nil? + + if place.lonlat.blank? place.lonlat = build_point_coordinates(data['geometry']['coordinates']) end end def save_places(places_to_create, places_to_update) - # Bulk insert for new places if places_to_create.any? place_attributes = places_to_create.map do |place| { @@ -136,7 +136,7 @@ class ReverseGeocoding::Places::FetchData end Place.insert_all(place_attributes) end - + # Individual updates for existing places places_to_update.each(&:save!) if places_to_update.any? end diff --git a/app/views/stats/_year.html.erb b/app/views/stats/_year.html.erb index 3d8989b8..fc5fd1e6 100644 --- a/app/views/stats/_year.html.erb +++ b/app/views/stats/_year.html.erb @@ -4,7 +4,9 @@
<%= column_chart( - @year_distances[year], + @year_distances[year].map { |month_name, distance_meters| + [month_name, Stat.convert_distance(distance_meters, current_user.safe_settings.distance_unit).round] + }, height: '200px', suffix: " #{current_user.safe_settings.distance_unit}", xtitle: 'Days',