From a84fde553e18a5418d2dfc5e14375b2486d3325c Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Tue, 23 Sep 2025 00:18:04 +0200 Subject: [PATCH] Fix failed specs --- app/services/location_search/result_aggregator.rb | 2 +- app/views/stats/public_month.html.erb | 7 +++---- spec/requests/api/v1/maps/hexagons_spec.rb | 10 +++++----- spec/serializers/api/point_serializer_spec.rb | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/services/location_search/result_aggregator.rb b/app/services/location_search/result_aggregator.rb index 52d5d950..1fc607f1 100644 --- a/app/services/location_search/result_aggregator.rb +++ b/app/services/location_search/result_aggregator.rb @@ -49,7 +49,7 @@ module LocationSearch # Calculate visit duration duration_minutes = - if sorted_points.any? + if sorted_points.length > 1 ((last_point[:timestamp] - first_point[:timestamp]) / 60.0).round else # Single point visit - estimate based on typical stay time diff --git a/app/views/stats/public_month.html.erb b/app/views/stats/public_month.html.erb index 1ac43763..560d285f 100644 --- a/app/views/stats/public_month.html.erb +++ b/app/views/stats/public_month.html.erb @@ -47,10 +47,9 @@
-

📍 Location Hexagons

- <% if @hexagons_available %> -
H3 Enhanced
- <% end %> +

+ <%= icon 'map' %> Location Hexagons +

diff --git a/spec/requests/api/v1/maps/hexagons_spec.rb b/spec/requests/api/v1/maps/hexagons_spec.rb index bc2aba2d..c0bb87a4 100644 --- a/spec/requests/api/v1/maps/hexagons_spec.rb +++ b/spec/requests/api/v1/maps/hexagons_spec.rb @@ -172,11 +172,11 @@ RSpec.describe 'Api::V1::Maps::Hexagons', type: :request do context 'with pre-calculated hexagon centers' do let(:pre_calculated_centers) do - { - '8a1fb46622dffff' => [5, 1_717_200_000, 1_717_203_600], # count, earliest, latest timestamps - '8a1fb46622e7fff' => [3, 1_717_210_000, 1_717_213_600], - '8a1fb46632dffff' => [8, 1_717_220_000, 1_717_223_600] - } + [ + ['8a1fb46622dffff', 5, 1_717_200_000, 1_717_203_600], # h3_index, count, earliest, latest timestamps + ['8a1fb46622e7fff', 3, 1_717_210_000, 1_717_213_600], + ['8a1fb46632dffff', 8, 1_717_220_000, 1_717_223_600] + ] end let(:stat) do create(:stat, :with_sharing_enabled, user:, year: 2024, month: 6, h3_hex_ids: pre_calculated_centers) diff --git a/spec/serializers/api/point_serializer_spec.rb b/spec/serializers/api/point_serializer_spec.rb index 4e4453e2..f6103419 100644 --- a/spec/serializers/api/point_serializer_spec.rb +++ b/spec/serializers/api/point_serializer_spec.rb @@ -7,7 +7,7 @@ RSpec.describe Api::PointSerializer do subject(:serializer) { described_class.new(point).call } let(:point) { create(:point) } - let(:all_excluded) { PointSerializer::EXCLUDED_ATTRIBUTES + Api::PointSerializer::ADDITIONAL_EXCLUDED_ATTRIBUTES } + let(:all_excluded) { Api::PointSerializer::EXCLUDED_ATTRIBUTES } let(:expected_json) do point.attributes.except(*all_excluded).tap do |attributes| # API serializer extracts coordinates from PostGIS geometry