diff --git a/CHANGELOG.md b/CHANGELOG.md index 1118ff41..c07c266a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). # [Unreleased] +### Added + +- `GET /api/v1/points/tracked_months` endpoint added to get list of tracked years and months. +- `GET /api/v1/countries/visited_cities` endpoint added to get list of visited cities. + ### Fixed - A point popup is no longer closes when hovering over a polyline. #536 diff --git a/app/controllers/api/v1/countries/visited_cities_controller.rb b/app/controllers/api/v1/countries/visited_cities_controller.rb index 2b79ffd7..85e53f7d 100644 --- a/app/controllers/api/v1/countries/visited_cities_controller.rb +++ b/app/controllers/api/v1/countries/visited_cities_controller.rb @@ -16,15 +16,7 @@ class Api::V1::Countries::VisitedCitiesController < ApiController private - def validate_params - missing_params = %i[start_at end_at].select { |param| params[param].blank? } - - if missing_params.any? - render json: { - error: "Missing required parameters: #{missing_params.join(', ')}" - }, status: :bad_request and return - end - - params.permit(:start_at, :end_at) + def required_params + %i[start_at end_at] end end diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 8e2b43e2..934cdc6b 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -15,4 +15,20 @@ class ApiController < ApplicationController def current_api_user @current_api_user ||= User.find_by(api_key: params[:api_key]) end + + def validate_params + missing_params = required_params.select { |param| params[param].blank? } + + if missing_params.any? + render json: { + error: "Missing required parameters: #{missing_params.join(', ')}" + }, status: :bad_request and return + end + + params.permit(*required_params) + end + + def required_params + [] + end end diff --git a/app/services/countries_and_cities.rb b/app/services/countries_and_cities.rb index b08f2e9a..0785107a 100644 --- a/app/services/countries_and_cities.rb +++ b/app/services/countries_and_cities.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true class CountriesAndCities - MIN_MINUTES_SPENT_IN_CITY = 30 # You can adjust this value as needed - CountryData = Struct.new(:country, :cities, keyword_init: true) CityData = Struct.new(:city, :points, :timestamp, :stayed_for, keyword_init: true) @@ -40,7 +38,7 @@ class CountriesAndCities end def build_city_data(city, points_count, timestamps, duration) - return nil if duration < MIN_MINUTES_SPENT_IN_CITY + return nil if duration < ::MIN_MINUTES_SPENT_IN_CITY CityData.new( city: city, diff --git a/app/views/shared/_right_sidebar.html.erb b/app/views/shared/_right_sidebar.html.erb deleted file mode 100644 index a0f6b2d6..00000000 --- a/app/views/shared/_right_sidebar.html.erb +++ /dev/null @@ -1,61 +0,0 @@ -<%= sidebar_distance(@distance) %> <%= sidebar_points(@points) %> - -
- -<% if REVERSE_GEOCODING_ENABLED && @countries_and_cities&.any? %> -