Update swagger docs and changelog

This commit is contained in:
Eugene Burmakin 2024-12-10 19:43:52 +01:00
parent d6b88ae9cb
commit dbb737a0c4
7 changed files with 54 additions and 18 deletions

View file

@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
# 0.19.4 - 2024-12-10
⚠️ This release introduces a breaking change. ⚠️
The `GET /api/v1/trips/:id/photos` endpoint now returns a different structure of the response:
```diff
{
id: 1,
latitude: 10,
longitude: 10,
localDateTime: "2024-01-01T00:00:00Z",
originalFileName: "photo.jpg",
city: "Berlin",
state: "Berlin",
country: "Germany",
type: "image",
+ orientation: "portrait",
source: "photoprism"
}
```
### Fixed
- Fixed a bug where the Photoprism photos were not being shown on the trip page.
@ -16,6 +36,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- A link to the Photoprism photos on the trip page if there are any.
- A `orientation` field in the Api::PhotoSerializer, hence the `GET /api/v1/photos` endpoint now includes the orientation of the photo. Valid values are `portrait` and `landscape`.
- Examples for the `type`, `orientation` and `source` fields in the `GET /api/v1/photos` endpoint in the Swagger UI.
# 0.19.3 - 2024-12-06

View file

@ -36,9 +36,7 @@ class MapController < ApplicationController
@distance ||= 0
@coordinates.each_cons(2) do
@distance += Geocoder::Calculations.distance_between(
[_1[0], _1[1]], [_2[0], _2[1]], units: DISTANCE_UNIT
)
@distance += DistanceCalculator.new([_1[0], _1[1]], [_2[0], _2[1]]).call
end
@distance.round(1)

View file

@ -35,6 +35,8 @@ class Trip < ApplicationRecord
vertical_photos = photos.select { |photo| photo[:orientation] == 'portrait' }
horizontal_photos = photos.select { |photo| photo[:orientation] == 'landscape' }
# this is ridiculous, but I couldn't find my way around frontend
# to show all photos in the same height
vertical_photos.count > horizontal_photos.count ? vertical_photos : horizontal_photos
end
@ -42,11 +44,7 @@ class Trip < ApplicationRecord
distance = 0
points.each_cons(2) do |point1, point2|
distance_between = Geocoder::Calculations.distance_between(
point1.to_coordinates, point2.to_coordinates, units: ::DISTANCE_UNIT
)
distance += distance_between
distance += DistanceCalculator.new(point1, point2).call
end
self.distance = distance.round

View file

@ -28,7 +28,9 @@ class Visit < ApplicationRecord
def default_radius
return area&.radius if area.present?
radius = points.map { Geocoder::Calculations.distance_between(center, [_1.latitude, _1.longitude]) }.max
radius = points.map do |point|
DistanceCalculator.new(center, [point.latitude, point.longitude]).call
end.max
radius && radius >= 15 ? radius : 15
end

View file

@ -116,7 +116,9 @@ RSpec.describe Trip, type: :model do
end
it 'returns the photos' do
expect(trip.photo_previews).to eq(expected_photos)
expect(trip.photo_previews).to include(expected_photos[0])
expect(trip.photo_previews).to include(expected_photos[1])
expect(trip.photo_previews.size).to eq(2)
end
end
end

View file

@ -110,9 +110,9 @@ RSpec.describe 'Api::V1::PhotosController', type: :request do
city: { type: :string },
state: { type: :string },
country: { type: :string },
type: { type: :string },
orientation: { type: :string },
source: { type: :string }
type: { type: :string, enum: %w[image video] },
orientation: { type: :string, enum: %w[portrait landscape] },
source: { type: :string, enum: %w[immich photoprism] }
},
required: %w[id latitude longitude localDateTime originalFileName city state country type source]
}
@ -143,9 +143,9 @@ RSpec.describe 'Api::V1::PhotosController', type: :request do
city: { type: :string },
state: { type: :string },
country: { type: :string },
type: { type: :string },
source: { type: :string },
orientation: { type: :string, enum: %w[portrait landscape] }
type: { type: :string, enum: %w[image video] },
orientation: { type: :string, enum: %w[portrait landscape] },
source: { type: :string, enum: %w[immich photoprism] }
}
let(:id) { '7fe486e3-c3ba-4b54-bbf9-1281b39ed15c' }

View file

@ -366,10 +366,19 @@ paths:
type: string
type:
type: string
enum:
- image
- video
orientation:
type: string
enum:
- portrait
- landscape
source:
type: string
enum:
- immich
- photoprism
required:
- id
- latitude
@ -431,13 +440,19 @@ paths:
type: string
type:
type: string
source:
type: string
enum:
- image
- video
orientation:
type: string
enum:
- portrait
- landscape
source:
type: string
enum:
- immich
- photoprism
'404':
description: photo not found
"/api/v1/points":