mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 01:31:39 -05:00
* Use user timezone to show dates on maps * Limit timestamps to valid range to prevent database errors when users enter pre-epoch dates. * Limit timestamps to valid range to prevent database errors when users enter pre-epoch dates. * Fix tests failing due to new index on stats table * Fix failing specs
25 lines
538 B
Ruby
25 lines
538 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Api::V1::Countries::VisitedCitiesController < ApiController
|
|
include SafeTimestampParser
|
|
|
|
before_action :validate_params
|
|
|
|
def index
|
|
start_at = safe_timestamp(params[:start_at])
|
|
end_at = safe_timestamp(params[:end_at])
|
|
|
|
points = current_api_user
|
|
.points
|
|
.without_raw_data
|
|
.where(timestamp: start_at..end_at)
|
|
|
|
render json: { data: CountriesAndCities.new(points).call }
|
|
end
|
|
|
|
private
|
|
|
|
def required_params
|
|
%i[start_at end_at]
|
|
end
|
|
end
|