dawarich/app/controllers/api/v1/countries/visited_cities_controller.rb

23 lines
486 B
Ruby
Raw Normal View History

2024-12-11 16:00:33 -05:00
# frozen_string_literal: true
class Api::V1::Countries::VisitedCitiesController < ApiController
before_action :validate_params
def index
start_at = DateTime.parse(params[:start_at]).to_i
end_at = DateTime.parse(params[:end_at]).to_i
points = current_api_user
.points
2024-12-11 16:00:33 -05:00
.where(timestamp: start_at..end_at)
render json: { data: CountriesAndCities.new(points).call }
end
private
def required_params
%i[start_at end_at]
2024-12-11 16:00:33 -05:00
end
end