2024-12-11 16:00:33 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
class Api::V1::Countries::VisitedCitiesController < ApiController
|
2025-12-08 18:17:24 -05:00
|
|
|
include SafeTimestampParser
|
|
|
|
|
|
2024-12-11 16:00:33 -05:00
|
|
|
before_action :validate_params
|
|
|
|
|
|
|
|
|
|
def index
|
2025-12-08 18:17:24 -05:00
|
|
|
start_at = safe_timestamp(params[:start_at])
|
|
|
|
|
end_at = safe_timestamp(params[:end_at])
|
2024-12-11 16:00:33 -05:00
|
|
|
|
|
|
|
|
points = current_api_user
|
2025-08-21 16:32:29 -04:00
|
|
|
.points
|
2025-12-08 15:38:56 -05:00
|
|
|
.without_raw_data
|
2024-12-11 16:00:33 -05:00
|
|
|
.where(timestamp: start_at..end_at)
|
|
|
|
|
|
|
|
|
|
render json: { data: CountriesAndCities.new(points).call }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
2024-12-16 09:42:26 -05:00
|
|
|
def required_params
|
2025-01-22 04:53:33 -05:00
|
|
|
%i[start_at end_at]
|
2024-12-11 16:00:33 -05:00
|
|
|
end
|
|
|
|
|
end
|