mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
Fix points controller to filter by start_at and end_at
This commit is contained in:
parent
bb528b429b
commit
4680b80284
1 changed files with 4 additions and 4 deletions
|
|
@ -6,11 +6,11 @@ class PointsController < ApplicationController
|
|||
end_at = params[:end_at]&.to_datetime.to_i
|
||||
|
||||
@points =
|
||||
if start_at && end_at
|
||||
Point.where('timestamp >= ? AND timestamp <= ?', start_at, end_at).order(timestamp: :asc)
|
||||
if start_at.positive? && end_at.positive?
|
||||
Point.where('timestamp >= ? AND timestamp <= ?', start_at, end_at)
|
||||
else
|
||||
Point.all.order(timestamp: :asc)
|
||||
end
|
||||
Point.all
|
||||
end.order(timestamp: :asc)
|
||||
|
||||
@countries_and_cities = @points.group_by(&:country).transform_values { _1.pluck(:city).uniq.compact }
|
||||
@coordinates = @points.pluck(:latitude, :longitude).map { [_1.to_f, _2.to_f] }
|
||||
|
|
|
|||
Loading…
Reference in a new issue