Update points relation

This commit is contained in:
Eugene Burmakin 2025-08-29 11:05:25 +02:00
parent 5ab382936d
commit 504bb92cdb
3 changed files with 19 additions and 19 deletions

View file

@ -62,7 +62,7 @@ class Tracks::TimeChunkProcessorJob < ApplicationJob
end
def load_chunk_points
user.tracked_points
user.points
.where(timestamp: chunk_data[:buffer_start_timestamp]..chunk_data[:buffer_end_timestamp])
.order(:timestamp)
end

View file

@ -44,13 +44,13 @@ class Tracks::TimeChunker
when start_at
[start_at.to_time, Time.current]
when end_at
first_point_time = user.tracked_points.minimum(:timestamp)
first_point_time = user.points.minimum(:timestamp)
return nil unless first_point_time
[Time.at(first_point_time), end_at.to_time]
else
# Get full range from user's points
first_point_time = user.tracked_points.minimum(:timestamp)
last_point_time = user.tracked_points.maximum(:timestamp)
first_point_time = user.points.minimum(:timestamp)
last_point_time = user.points.maximum(:timestamp)
return nil unless first_point_time && last_point_time
[Time.at(first_point_time), Time.at(last_point_time)]
@ -77,7 +77,7 @@ class Tracks::TimeChunker
def chunk_has_points?(chunk)
# Check if there are any points in the buffer range to avoid empty chunks
user.tracked_points
user.points
.where(timestamp: chunk[:buffer_start_timestamp]..chunk[:buffer_end_timestamp])
.exists?
end

View file

@ -200,7 +200,7 @@ RSpec.describe Tracks::TimeChunker do
expect(chunks).not_to be_empty
chunks.each do |chunk|
# Verify each chunk has points in its buffer range
points_exist = user.tracked_points
points_exist = user.points
.where(timestamp: chunk[:buffer_start_timestamp]..chunk[:buffer_end_timestamp])
.exists?
expect(points_exist).to be true