dawarich/app/controllers/points_controller.rb

14 lines
464 B
Ruby
Raw Normal View History

2024-03-15 18:27:31 -04:00
class PointsController < ApplicationController
before_action :authenticate_user!
2024-03-15 18:27:31 -04:00
def index
start_at = params[:start_at].to_datetime.to_i
end_at = params[:end_at].to_datetime.to_i
@points = Point.all.order(timestamp: :asc)
@points = Point.all.where('timestamp >= ? AND timestamp <= ?', start_at, end_at).order(timestamp: :asc) if start_at && end_at
2024-03-15 18:27:31 -04:00
@coordinates = @points.pluck(:latitude, :longitude).map { [_1.to_f, _2.to_f] }
2024-03-15 18:27:31 -04:00
end
end