diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6afdc81c..ec16e47e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,7 +9,8 @@ TODO:
- Specs for app/services/visits/merge_service.rb and rename it probably
- Remove Stimulus controllers for visits on the Visits page
- Revert changes to Visits page
-
+- Decide on how to suggest visits for the past
+- Should visits be disabled for non-reverse-geocoded instances?
# 0.25.0 - 2025-03-08
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
index d6a6ecf3..e7913676 100644
--- a/app/assets/stylesheets/application.css
+++ b/app/assets/stylesheets/application.css
@@ -14,17 +14,6 @@
*= require_self
*/
-/* Leaflet map container styles */
-[data-controller="visits-map"] {
- height: 100%;
- width: 100%;
-}
-
-[data-visits-map-target="container"] {
- height: 100%;
- width: 100%;
-}
-
/* Loading spinner animation */
@keyframes spinner {
to {
diff --git a/app/javascript/maps/visits.js b/app/javascript/maps/visits.js
index 4256cdb3..5e3f4d8c 100644
--- a/app/javascript/maps/visits.js
+++ b/app/javascript/maps/visits.js
@@ -101,7 +101,7 @@ export class VisitsManager {
const SelectionControl = L.Control.extend({
onAdd: (map) => {
const button = L.DomUtil.create('button', 'leaflet-bar leaflet-control leaflet-control-custom');
- button.innerHTML = '';
+ button.innerHTML = '📌';
button.title = 'Select Area';
button.id = 'selection-tool-button';
button.style.width = '48px';
diff --git a/app/jobs/data_migrations/migrate_places_lonlat_job.rb b/app/jobs/data_migrations/migrate_places_lonlat_job.rb
index e4ba1e33..b71f0f55 100644
--- a/app/jobs/data_migrations/migrate_places_lonlat_job.rb
+++ b/app/jobs/data_migrations/migrate_places_lonlat_job.rb
@@ -6,8 +6,24 @@ class DataMigrations::MigratePlacesLonlatJob < ApplicationJob
def perform(user_id)
user = User.find(user_id)
- # rubocop:disable Rails/SkipsModelValidations
- user.places.update_all('lonlat = ST_SetSRID(ST_MakePoint(longitude, latitude), 4326)')
- # rubocop:enable Rails/SkipsModelValidations
+ # Find all places with nil lonlat
+ places_to_update = user.places.where(lonlat: nil)
+
+ # For each place, set the lonlat value based on longitude and latitude
+ places_to_update.find_each do |place|
+ next if place.longitude.nil? || place.latitude.nil?
+
+ # Set the lonlat to a PostGIS point with the proper SRID
+ # rubocop:disable Rails/SkipsModelValidations
+ place.update_column(:lonlat, "SRID=4326;POINT(#{place.longitude} #{place.latitude})")
+ # rubocop:enable Rails/SkipsModelValidations
+ end
+
+ # Double check if there are any remaining places without lonlat
+ remaining = user.places.where(lonlat: nil)
+ return unless remaining.exists?
+
+ # Log an error for these places
+ Rails.logger.error("Places with ID #{remaining.pluck(:id).join(', ')} for user #{user.id} could not be updated with lonlat values")
end
end
diff --git a/app/services/visits/smart_detect.rb b/app/services/visits/smart_detect.rb
index 04864dee..64d66440 100644
--- a/app/services/visits/smart_detect.rb
+++ b/app/services/visits/smart_detect.rb
@@ -22,8 +22,8 @@ module Visits
return [] if points.empty?
potential_visits = Visits::Detector.new(points).detect_potential_visits
- merged_visits = Visits::Merger.new(points).merge_visits(potential_visits)
- grouped_visits = group_nearby_visits(merged_visits).flatten
+ merged_visits = Visits::Merger.new(points).merge_visits(potential_visits)
+ grouped_visits = group_nearby_visits(merged_visits).flatten
Visits::Creator.new(user).create_visits(grouped_visits)
end
diff --git a/app/services/visits/time_chunks.rb b/app/services/visits/time_chunks.rb
index d7fc2738..5c7470da 100644
--- a/app/services/visits/time_chunks.rb
+++ b/app/services/visits/time_chunks.rb
@@ -11,16 +11,8 @@ module Visits
def call
# If the start date is in the future or equal to the end date,
# handle as a special case extending to the end of the start's year
- if start_at >= end_at
- year_end = start_at.end_of_year
- return [start_at...year_end]
- end
-
- # Special case for dates within the same year
- if start_at.year == end_at.year
- year_end = start_at.end_of_year
- return [start_at...year_end]
- end
+ # or if the start and end are in the same year, return the year chunk
+ return [start_at..start_at.end_of_year] if start_in_future? || same_year?
# First chunk: from start_at to end of that year
first_end = start_at.end_of_year
@@ -43,5 +35,13 @@ module Visits
private
attr_reader :start_at, :end_at, :time_chunks
+
+ def start_in_future?
+ start_at >= end_at
+ end
+
+ def same_year?
+ start_at.year == end_at.year
+ end
end
end
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 2cc1d82e..f41baeda 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -10,7 +10,6 @@
-
<%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %>
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
diff --git a/app/views/visits/_visit.html.erb b/app/views/visits/_visit.html.erb
index be72f2ea..c5de1ce7 100644
--- a/app/views/visits/_visit.html.erb
+++ b/app/views/visits/_visit.html.erb
@@ -1,8 +1,4 @@
-
- <%# Main content area with map and side panel %>
-
- <%# Map container %>
-
-
+
+
+ Visits suggestion feature is currently in beta stage. Expect bugs and problems and don't hesitate to report them to Github Issues.
+
+
+ <% if @visits.empty? %>
+
+
+
+
Hello there!
+
+ Here you'll find your <%= params[:status] %> visits, but now there are none. Create some areas on your map and pretty soon you'll see visit suggestions on this page!
+
-
- Visits suggestion feature is currently in beta stage. Expect bugs and problems and don't hesitate to report them to Github Issues.
-
-
- <%# Visits list %>
-
- <% if @visits.empty? %>
-
-
No visits found
-
- Here you'll find your <%= params[:status] %> visits, but now there are none. Create some areas on your map and pretty soon you'll see visit suggestions on this page!
-