mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
Prevent places duplicates
This commit is contained in:
parent
6b356d24b1
commit
1ce66a1494
2 changed files with 13 additions and 1 deletions
|
|
@ -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/)
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
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
|
# 0.24.2 - 2025-02-24
|
||||||
|
|
||||||
## Added
|
## Added
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,20 @@ class VisitSuggestingJob < ApplicationJob
|
||||||
|
|
||||||
def perform(user_ids: [], start_at: 1.day.ago, end_at: Time.current)
|
def perform(user_ids: [], start_at: 1.day.ago, end_at: Time.current)
|
||||||
users = user_ids.any? ? User.where(id: user_ids) : User.all
|
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|
|
users.find_each do |user|
|
||||||
next unless user.active?
|
next unless user.active?
|
||||||
next if user.tracked_points.empty?
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue