Prevent places duplicates

This commit is contained in:
Eugene Burmakin 2025-03-05 22:36:56 +01:00
parent 6b356d24b1
commit 1ce66a1494
2 changed files with 13 additions and 1 deletions

View file

@ -4,6 +4,10 @@ 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/).
TODO:
- Selecting a visit should put it above other visits on the map to make it easier to edit it. If many visits are on the same place, we should be able to click on them
# 0.24.2 - 2025-02-24
## Added

View file

@ -6,12 +6,20 @@ class VisitSuggestingJob < ApplicationJob
def perform(user_ids: [], start_at: 1.day.ago, end_at: Time.current)
users = user_ids.any? ? User.where(id: user_ids) : User.all
start_at = start_at.to_datetime
end_at = end_at.to_datetime
users.find_each do |user|
next unless user.active?
next if user.tracked_points.empty?
Visits::Suggest.new(user, start_at:, end_at:).call
# Split the time range into 24-hour chunks
# This prevents from places duplicates
time_chunks = (start_at..end_at).step(1.day).to_a
time_chunks.each do |time_chunk|
Visits::Suggest.new(user, start_at: time_chunk, end_at: time_chunk + 1.day).call
end
end
end
end