mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 01:31:39 -05:00
Fix potential issue with time range data types
This commit is contained in:
parent
1f5325d9bb
commit
f5ef2ab9ef
1 changed files with 26 additions and 2 deletions
|
|
@ -73,7 +73,7 @@ class Tracks::Generator
|
|||
|
||||
def load_bulk_points
|
||||
scope = user.tracked_points.order(:timestamp)
|
||||
scope = scope.where(timestamp: time_range) if time_range_defined?
|
||||
scope = scope.where(timestamp: timestamp_range) if time_range_defined?
|
||||
|
||||
scope
|
||||
end
|
||||
|
|
@ -109,7 +109,31 @@ class Tracks::Generator
|
|||
def time_range
|
||||
return nil unless time_range_defined?
|
||||
|
||||
Time.at(start_at&.to_i)..Time.at(end_at&.to_i)
|
||||
start_time = start_at&.to_i
|
||||
end_time = end_at&.to_i
|
||||
|
||||
if start_time && end_time
|
||||
Time.zone.at(start_time)..Time.zone.at(end_time)
|
||||
elsif start_time
|
||||
Time.zone.at(start_time)..
|
||||
elsif end_time
|
||||
..Time.zone.at(end_time)
|
||||
end
|
||||
end
|
||||
|
||||
def timestamp_range
|
||||
return nil unless time_range_defined?
|
||||
|
||||
start_time = start_at&.to_i
|
||||
end_time = end_at&.to_i
|
||||
|
||||
if start_time && end_time
|
||||
start_time..end_time
|
||||
elsif start_time
|
||||
start_time..
|
||||
elsif end_time
|
||||
..end_time
|
||||
end
|
||||
end
|
||||
|
||||
def daily_time_range
|
||||
|
|
|
|||
Loading…
Reference in a new issue