From c99f6597f0948e74ea3eeeceb3462da7eb14d00a Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Wed, 19 Nov 2025 21:40:43 +0100 Subject: [PATCH] Revert some changes --- .../controllers/stat_page_controller.js | 41 +------------------ app/services/users/import_data/places.rb | 2 +- app/views/stats/_month.html.erb | 33 --------------- spec/models/tag_spec.rb | 3 ++ spec/requests/api/v1/maps/hexagons_spec.rb | 2 - spec/requests/family/invitations_spec.rb | 2 - spec/requests/family_workflows_spec.rb | 2 - spec/requests/imports_spec.rb | 2 - spec/requests/map_spec.rb | 2 - spec/requests/notifications_spec.rb | 2 - .../requests/settings/background_jobs_spec.rb | 2 - spec/requests/settings/maps_spec.rb | 2 - spec/requests/stats_spec.rb | 2 - spec/requests/users/registrations_spec.rb | 2 - spec/requests/users_spec.rb | 2 - spec/serializers/api/place_serializer_spec.rb | 1 + .../places/fetch_data_spec.rb | 9 +--- spec/services/visits/creator_spec.rb | 4 +- 18 files changed, 10 insertions(+), 105 deletions(-) diff --git a/app/javascript/controllers/stat_page_controller.js b/app/javascript/controllers/stat_page_controller.js index 0730c5a5..e2e94184 100644 --- a/app/javascript/controllers/stat_page_controller.js +++ b/app/javascript/controllers/stat_page_controller.js @@ -1,11 +1,10 @@ import L from "leaflet"; import "leaflet.heat"; import { createAllMapLayers } from "../maps/layers"; -import { PlacesManager } from "../maps/places"; import BaseController from "./base_controller"; export default class extends BaseController { - static targets = ["map", "loading", "heatmapBtn", "pointsBtn", "placesBtn"]; + static targets = ["map", "loading", "heatmapBtn", "pointsBtn"]; connect() { super.connect(); @@ -65,10 +64,6 @@ export default class extends BaseController { this.markersLayer = L.layerGroup(); // Don't add to map initially this.heatmapLayer = null; - // Initialize Places Manager - this.placesManager = new PlacesManager(this.map, this.apiKey); - this.placesManager.initialize(); - // Load data for this month this.loadMonthData(); @@ -233,40 +228,6 @@ export default class extends BaseController { } } - togglePlaces() { - if (!this.placesManager) { - console.warn("Places manager not initialized"); - return; - } - - if (this.map.hasLayer(this.placesManager.placesLayer)) { - // Remove places layer - this.map.removeLayer(this.placesManager.placesLayer); - if (this.hasPlacesBtnTarget) { - this.placesBtnTarget.classList.remove('btn-active'); - } - } else { - // Add places layer - this.map.addLayer(this.placesManager.placesLayer); - if (this.hasPlacesBtnTarget) { - this.placesBtnTarget.classList.add('btn-active'); - } - } - } - - filterPlacesByTags(event) { - if (!this.placesManager) return; - - // Collect all checked tag IDs - const checkboxes = event.currentTarget.closest('[data-controller="stat-page"]').querySelectorAll('input[type="checkbox"][data-tag-id]'); - const selectedTagIds = Array.from(checkboxes) - .filter(cb => cb.checked) - .map(cb => parseInt(cb.dataset.tagId)); - - // Filter places by selected tags (or show all if none selected) - this.placesManager.filterByTags(selectedTagIds.length > 0 ? selectedTagIds : null); - } - showLoading(show) { if (this.hasLoadingTarget) { this.loadingTarget.style.display = show ? 'flex' : 'none'; diff --git a/app/services/users/import_data/places.rb b/app/services/users/import_data/places.rb index 5011bdd5..cab8a3f6 100644 --- a/app/services/users/import_data/places.rb +++ b/app/services/users/import_data/places.rb @@ -91,7 +91,7 @@ class Users::ImportData::Places logger.debug "No exact match found for #{name} at (#{latitude}, #{longitude}). Creating new place." place_attributes = place_data.except('created_at', 'updated_at', 'latitude', 'longitude') - # lonlat will be auto-generated by the Place model's before_validation callback + place_attributes['lonlat'] = "POINT(#{longitude} #{latitude})" place_attributes['latitude'] = latitude place_attributes['longitude'] = longitude place_attributes['user_id'] = user.id diff --git a/app/views/stats/_month.html.erb b/app/views/stats/_month.html.erb index 9004b046..1c16abf5 100644 --- a/app/views/stats/_month.html.erb +++ b/app/views/stats/_month.html.erb @@ -70,9 +70,6 @@ - @@ -86,33 +83,6 @@ - - <% if current_user.tags.any? %> -
-

- <%= icon 'filter' %> Filter Places by Tags -

-
- <% current_user.tags.ordered.each do |tag| %> - - <% end %> -
-
- <%= icon 'info' %> Select tags to filter places on the map. Uncheck all to show all places. -
-
- <% end %> - <%= render 'shared/sharing_modal' %> - - -<%= render 'shared/place_creation_modal' %> diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb index 640a4ab1..bc0335d6 100644 --- a/spec/models/tag_spec.rb +++ b/spec/models/tag_spec.rb @@ -8,6 +8,9 @@ RSpec.describe Tag, type: :model do it { is_expected.to have_many(:places).through(:taggings) } it { is_expected.to validate_presence_of(:name) } + it { is_expected.to validate_length_of(:icon).is_at_most(10) } + it { is_expected.to allow_value(nil).for(:icon) } + it { is_expected.to validate_numericality_of(:privacy_radius_meters).is_greater_than(0).is_less_than_or_equal_to(5000).allow_nil } describe 'validations' do subject { create(:tag) } diff --git a/spec/requests/api/v1/maps/hexagons_spec.rb b/spec/requests/api/v1/maps/hexagons_spec.rb index f301fd5b..5b82c1e0 100644 --- a/spec/requests/api/v1/maps/hexagons_spec.rb +++ b/spec/requests/api/v1/maps/hexagons_spec.rb @@ -5,8 +5,6 @@ require 'rails_helper' RSpec.describe 'Api::V1::Maps::Hexagons', type: :request do let(:user) { create(:user) } - - describe 'GET /api/v1/maps/hexagons' do let(:valid_params) do { diff --git a/spec/requests/family/invitations_spec.rb b/spec/requests/family/invitations_spec.rb index 2c0840c2..657ac1d5 100644 --- a/spec/requests/family/invitations_spec.rb +++ b/spec/requests/family/invitations_spec.rb @@ -8,8 +8,6 @@ RSpec.describe 'Family::Invitations', type: :request do let!(:membership) { create(:family_membership, user: user, family: family, role: :owner) } let(:invitation) { create(:family_invitation, family: family, invited_by: user) } - - describe 'GET /family/invitations' do before { sign_in user } diff --git a/spec/requests/family_workflows_spec.rb b/spec/requests/family_workflows_spec.rb index 7b2bccf4..4942159b 100644 --- a/spec/requests/family_workflows_spec.rb +++ b/spec/requests/family_workflows_spec.rb @@ -7,8 +7,6 @@ RSpec.describe 'Family Workflows', type: :request do let(:user2) { create(:user, email: 'bob@example.com') } let(:user3) { create(:user, email: 'charlie@example.com') } - - describe 'Complete family creation and management workflow' do it 'allows creating a family, inviting members, and managing the family' do # Step 1: User1 creates a family diff --git a/spec/requests/imports_spec.rb b/spec/requests/imports_spec.rb index 8c1b8c90..71ed302c 100644 --- a/spec/requests/imports_spec.rb +++ b/spec/requests/imports_spec.rb @@ -3,8 +3,6 @@ require 'rails_helper' RSpec.describe 'Imports', type: :request do - - describe 'GET /imports' do context 'when user is logged in' do let(:user) { create(:user) } diff --git a/spec/requests/map_spec.rb b/spec/requests/map_spec.rb index 249a465f..f9acca09 100644 --- a/spec/requests/map_spec.rb +++ b/spec/requests/map_spec.rb @@ -3,8 +3,6 @@ require 'rails_helper' RSpec.describe 'Map', type: :request do - - describe 'GET /index' do context 'when user signed in' do let(:user) { create(:user) } diff --git a/spec/requests/notifications_spec.rb b/spec/requests/notifications_spec.rb index 57a293b0..aba0c12e 100644 --- a/spec/requests/notifications_spec.rb +++ b/spec/requests/notifications_spec.rb @@ -3,8 +3,6 @@ require 'rails_helper' RSpec.describe '/notifications', type: :request do - - context 'when user is not logged in' do it 'redirects to the login page' do get notifications_url diff --git a/spec/requests/settings/background_jobs_spec.rb b/spec/requests/settings/background_jobs_spec.rb index 0ba45f9c..2e6c69af 100644 --- a/spec/requests/settings/background_jobs_spec.rb +++ b/spec/requests/settings/background_jobs_spec.rb @@ -3,8 +3,6 @@ require 'rails_helper' RSpec.describe '/settings/background_jobs', type: :request do - - context 'when Dawarich is in self-hosted mode' do before do allow(DawarichSettings).to receive(:self_hosted?).and_return(true) diff --git a/spec/requests/settings/maps_spec.rb b/spec/requests/settings/maps_spec.rb index 698e79a9..f61fd3f7 100644 --- a/spec/requests/settings/maps_spec.rb +++ b/spec/requests/settings/maps_spec.rb @@ -3,8 +3,6 @@ require 'rails_helper' RSpec.describe 'settings/maps', type: :request do - - context 'when user is authenticated' do let!(:user) { create(:user) } diff --git a/spec/requests/stats_spec.rb b/spec/requests/stats_spec.rb index fbf3e313..d3af4956 100644 --- a/spec/requests/stats_spec.rb +++ b/spec/requests/stats_spec.rb @@ -3,8 +3,6 @@ require 'rails_helper' RSpec.describe '/stats', type: :request do - - context 'when user is not signed in' do describe 'GET /index' do it 'redirects to the sign in page' do diff --git a/spec/requests/users/registrations_spec.rb b/spec/requests/users/registrations_spec.rb index d19ccc5f..5cbe54a8 100644 --- a/spec/requests/users/registrations_spec.rb +++ b/spec/requests/users/registrations_spec.rb @@ -10,8 +10,6 @@ RSpec.describe 'Users::Registrations', type: :request do create(:family_invitation, family: family, invited_by: family_owner, email: 'invited@example.com') end - - describe 'Family Invitation Registration Flow' do context 'when accessing registration with a valid invitation token' do it 'shows family-focused registration page' do diff --git a/spec/requests/users_spec.rb b/spec/requests/users_spec.rb index 6e61fbe6..913b5778 100644 --- a/spec/requests/users_spec.rb +++ b/spec/requests/users_spec.rb @@ -3,8 +3,6 @@ require 'rails_helper' RSpec.describe 'Users', type: :request do - - describe 'GET /users/sign_up' do context 'when self-hosted' do before do diff --git a/spec/serializers/api/place_serializer_spec.rb b/spec/serializers/api/place_serializer_spec.rb index 5aeb232f..fe80542b 100644 --- a/spec/serializers/api/place_serializer_spec.rb +++ b/spec/serializers/api/place_serializer_spec.rb @@ -11,6 +11,7 @@ RSpec.describe Api::PlaceSerializer do name: 'Central Park', longitude: -73.9665, latitude: 40.7812, + lonlat: 'SRID=4326;POINT(-73.9665 40.7812)', city: 'New York', country: 'United States', source: 'photon', diff --git a/spec/services/reverse_geocoding/places/fetch_data_spec.rb b/spec/services/reverse_geocoding/places/fetch_data_spec.rb index c95562f2..399b31c0 100644 --- a/spec/services/reverse_geocoding/places/fetch_data_spec.rb +++ b/spec/services/reverse_geocoding/places/fetch_data_spec.rb @@ -591,7 +591,7 @@ RSpec.describe ReverseGeocoding::Places::FetchData do end context 'when lonlat is already present on existing place' do - let!(:existing_place) { create(:place, :with_geodata, latitude: 50.0, longitude: 10.0) } + let!(:existing_place) { create(:place, :with_geodata, lonlat: 'POINT(10.0 50.0)') } let(:existing_data) do double( data: { @@ -600,9 +600,7 @@ RSpec.describe ReverseGeocoding::Places::FetchData do 'osm_id' => existing_place.geodata.dig('properties', 'osm_id'), 'name' => 'Updated Name' } - }, - latitude: 55.0, - longitude: 15.0 + } ) end @@ -614,10 +612,7 @@ RSpec.describe ReverseGeocoding::Places::FetchData do service.call existing_place.reload - # lonlat is auto-generated from latitude/longitude, so it should remain based on original coordinates expect(existing_place.lonlat.to_s).to eq('POINT (10.0 50.0)') - expect(existing_place.latitude).to eq(50.0) - expect(existing_place.longitude).to eq(10.0) end end end diff --git a/spec/services/visits/creator_spec.rb b/spec/services/visits/creator_spec.rb index fd048d1b..dad0bef0 100644 --- a/spec/services/visits/creator_spec.rb +++ b/spec/services/visits/creator_spec.rb @@ -25,7 +25,7 @@ RSpec.describe Visits::Creator do end context 'when a confirmed visit already exists at the same location' do - let(:place) { create(:place, user: user, latitude: 40.7128, longitude: -74.0060, name: 'Existing Place') } + let(:place) { create(:place, lonlat: 'POINT(-74.0060 40.7128)', name: 'Existing Place') } let!(:existing_visit) do create( :visit, @@ -61,7 +61,7 @@ RSpec.describe Visits::Creator do end context 'when a confirmed visit exists but at a different location' do - let(:different_place) { create(:place, user: user, latitude: 41.0000, longitude: -73.9000, name: 'Different Place') } + let(:different_place) { create(:place, lonlat: 'POINT(-73.9000 41.0000)', name: 'Different Place') } let!(:existing_visit) do create( :visit,