mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
Update points relation
This commit is contained in:
parent
5ab382936d
commit
504bb92cdb
3 changed files with 19 additions and 19 deletions
|
|
@ -62,7 +62,7 @@ class Tracks::TimeChunkProcessorJob < ApplicationJob
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_chunk_points
|
def load_chunk_points
|
||||||
user.tracked_points
|
user.points
|
||||||
.where(timestamp: chunk_data[:buffer_start_timestamp]..chunk_data[:buffer_end_timestamp])
|
.where(timestamp: chunk_data[:buffer_start_timestamp]..chunk_data[:buffer_end_timestamp])
|
||||||
.order(:timestamp)
|
.order(:timestamp)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -44,13 +44,13 @@ class Tracks::TimeChunker
|
||||||
when start_at
|
when start_at
|
||||||
[start_at.to_time, Time.current]
|
[start_at.to_time, Time.current]
|
||||||
when end_at
|
when end_at
|
||||||
first_point_time = user.tracked_points.minimum(:timestamp)
|
first_point_time = user.points.minimum(:timestamp)
|
||||||
return nil unless first_point_time
|
return nil unless first_point_time
|
||||||
[Time.at(first_point_time), end_at.to_time]
|
[Time.at(first_point_time), end_at.to_time]
|
||||||
else
|
else
|
||||||
# Get full range from user's points
|
# Get full range from user's points
|
||||||
first_point_time = user.tracked_points.minimum(:timestamp)
|
first_point_time = user.points.minimum(:timestamp)
|
||||||
last_point_time = user.tracked_points.maximum(:timestamp)
|
last_point_time = user.points.maximum(:timestamp)
|
||||||
|
|
||||||
return nil unless first_point_time && last_point_time
|
return nil unless first_point_time && last_point_time
|
||||||
[Time.at(first_point_time), Time.at(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)
|
def chunk_has_points?(chunk)
|
||||||
# Check if there are any points in the buffer range to avoid empty chunks
|
# 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])
|
.where(timestamp: chunk[:buffer_start_timestamp]..chunk[:buffer_end_timestamp])
|
||||||
.exists?
|
.exists?
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ RSpec.describe Tracks::TimeChunker do
|
||||||
expect(chunks).not_to be_empty
|
expect(chunks).not_to be_empty
|
||||||
chunks.each do |chunk|
|
chunks.each do |chunk|
|
||||||
# Verify each chunk has points in its buffer range
|
# 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])
|
.where(timestamp: chunk[:buffer_start_timestamp]..chunk[:buffer_end_timestamp])
|
||||||
.exists?
|
.exists?
|
||||||
expect(points_exist).to be true
|
expect(points_exist).to be true
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue