From 5c09e5b0f91a48da9f15291fe5af9483a6ed346e Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Thu, 28 Nov 2024 16:11:04 +0100 Subject: [PATCH] Move trip to partial --- CHANGELOG.md | 20 +++++++++++++++++++- app/helpers/trips_helper.rb | 2 -- app/models/trip.rb | 2 +- app/services/immich/request_photos.rb | 2 +- app/views/trips/_trip.html.erb | 26 ++++++++++++++++++++++++-- app/views/trips/index.html.erb | 25 +------------------------ config/routes.rb | 2 +- db/schema.rb | 16 ---------------- 8 files changed, 47 insertions(+), 48 deletions(-) delete mode 100644 app/helpers/trips_helper.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index cb89cc9f..1373d0fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,25 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -# 0.17.1 - 2024-11-27 +# 0.18.0 - 2024-11-28 + +## The Trips release + +You can now create, edit and delete trips. To create a trip, click on the "New Trip" button on the Trips page. Provide a name, date and time for start and end of the trip. You can add your own notes to the trip as well. + +If you have points tracked during provided timeframe, they will be automatically added to the trip and will be shown on the trip map. + +Also, if you have Immich integrated, you will see photos from the trip on the trip page, along with a link to look at them on Immich. + +### Added + +- The Trips feature. Read above for more details. + +### Changed + +- Maps are now not so rough on the edges. + +# 0.17.2 - 2024-11-27 ### Fixed diff --git a/app/helpers/trips_helper.rb b/app/helpers/trips_helper.rb deleted file mode 100644 index 04f333d4..00000000 --- a/app/helpers/trips_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module TripsHelper -end diff --git a/app/models/trip.rb b/app/models/trip.rb index 44f202ab..22688770 100644 --- a/app/models/trip.rb +++ b/app/models/trip.rb @@ -22,7 +22,7 @@ class Trip < ApplicationRecord user, start_date: started_at.to_date.to_s, end_date: ended_at.to_date.to_s - ).call + ).call.reject { |asset| asset['type'].downcase == 'video' } # let's count what photos are more: vertical or horizontal and select the ones that are more vertical_photos = immich_photos.select { _1['exifInfo']['orientation'] == '6' } diff --git a/app/services/immich/request_photos.rb b/app/services/immich/request_photos.rb index c60dbcec..0f1eabc7 100644 --- a/app/services/immich/request_photos.rb +++ b/app/services/immich/request_photos.rb @@ -52,7 +52,7 @@ class Immich::RequestPhotos page += 1 end - data.flatten.reject { |asset| asset['type'].downcase == 'video' } + data.flatten end def headers diff --git a/app/views/trips/_trip.html.erb b/app/views/trips/_trip.html.erb index 87b36e7f..fd43c6cc 100644 --- a/app/views/trips/_trip.html.erb +++ b/app/views/trips/_trip.html.erb @@ -1,2 +1,24 @@ -
-
+<%= link_to trip, class: "block hover:shadow-lg rounded-lg" do %> +
+
+

+ <%= trip.name %> +

+

+ <%= "#{human_date(trip.started_at)} – #{human_date(trip.ended_at)}, #{trip.distance} #{DISTANCE_UNIT}" %> +

+ +
+
+
+
+<% end %> diff --git a/app/views/trips/index.html.erb b/app/views/trips/index.html.erb index eb0c2078..c5819413 100644 --- a/app/views/trips/index.html.erb +++ b/app/views/trips/index.html.erb @@ -27,30 +27,7 @@
<% @trips.each do |trip| %> - <%= link_to trip, class: "block hover:shadow-lg rounded-lg" do %> -
-
-

- <%= trip.name %> -

-

- <%= "#{human_date(trip.started_at)} – #{human_date(trip.ended_at)}, #{trip.distance} #{DISTANCE_UNIT}" %> -

- -
-
-
-
- <% end %> + <%= render 'trip', trip: trip %> <% end %>
<% end %> diff --git a/config/routes.rb b/config/routes.rb index 78474586..2c40e93d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,7 +3,6 @@ require 'sidekiq/web' Rails.application.routes.draw do - resources :trips mount ActionCable.server => '/cable' mount Rswag::Api::Engine => '/api-docs' mount Rswag::Ui::Engine => '/api-docs' @@ -31,6 +30,7 @@ Rails.application.routes.draw do resources :visits, only: %i[index update] resources :places, only: %i[index destroy] resources :exports, only: %i[index create destroy] + resources :trips resources :points, only: %i[index] do collection do delete :bulk_destroy diff --git a/db/schema.rb b/db/schema.rb index aa3daa37..3e1a538f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -196,21 +196,6 @@ ActiveRecord::Schema[7.2].define(version: 2024_11_28_095325) do t.index ["user_id"], name: "index_trips_on_user_id" end - create_table "user_digests", force: :cascade do |t| - t.bigint "user_id", null: false - t.integer "kind", default: 0, null: false - t.datetime "start_at", null: false - t.datetime "end_at" - t.integer "distance", default: 0, null: false - t.text "countries", default: [], array: true - t.text "cities", default: [], array: true - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["distance"], name: "index_user_digests_on_distance" - t.index ["kind"], name: "index_user_digests_on_kind" - t.index ["user_id"], name: "index_user_digests_on_user_id" - end - create_table "users", force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false @@ -253,7 +238,6 @@ ActiveRecord::Schema[7.2].define(version: 2024_11_28_095325) do add_foreign_key "points", "visits" add_foreign_key "stats", "users" add_foreign_key "trips", "users" - add_foreign_key "user_digests", "users" add_foreign_key "visits", "areas" add_foreign_key "visits", "places" add_foreign_key "visits", "users"