From 1733b2b73257d06bac896743cb6fec743529a1b8 Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Tue, 10 Dec 2024 23:10:36 +0100 Subject: [PATCH] Fix map and visits pages --- .app_version | 2 +- CHANGELOG.md | 6 ++++++ app/controllers/map_controller.rb | 2 +- app/models/visit.rb | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.app_version b/.app_version index c0b8d590..16235ea2 100644 --- a/.app_version +++ b/.app_version @@ -1 +1 @@ -0.19.4 +0.19.5 diff --git a/CHANGELOG.md b/CHANGELOG.md index f25bc46d..31d488f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,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/). +# 0.19.5 - 2024-12-10 + +### Fixed + +- Fixed a bug where the map and visits pages were throwing an error due to incorrect approach to distance calculation. + # 0.19.4 - 2024-12-10 ⚠️ This release introduces a breaking change. ⚠️ diff --git a/app/controllers/map_controller.rb b/app/controllers/map_controller.rb index 93657bd4..ac960928 100644 --- a/app/controllers/map_controller.rb +++ b/app/controllers/map_controller.rb @@ -36,7 +36,7 @@ class MapController < ApplicationController @distance ||= 0 @coordinates.each_cons(2) do - @distance += DistanceCalculator.new([_1[0], _1[1]], [_2[0], _2[1]]).call + @distance += Geocoder::Calculations.distance_between([_1[0], _1[1]], [_2[0], _2[1]]) end @distance.round(1) diff --git a/app/models/visit.rb b/app/models/visit.rb index bfd5b3d0..ddd6124f 100644 --- a/app/models/visit.rb +++ b/app/models/visit.rb @@ -29,7 +29,7 @@ class Visit < ApplicationRecord return area&.radius if area.present? radius = points.map do |point| - DistanceCalculator.new(center, [point.latitude, point.longitude]).call + Geocoder::Calculations.distance_between(center, [point.latitude, point.longitude]) end.max radius && radius >= 15 ? radius : 15