From b712332277bfdf1ba9aa4fe096d260c1e7515fc2 Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Thu, 28 Nov 2024 10:51:11 +0100 Subject: [PATCH] Update link to Immich search on the trip page --- app/helpers/application_helper.rb | 10 ++++++++++ app/views/trips/show.html.erb | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3fe89204..5495369b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -110,4 +110,14 @@ module ApplicationHelper def human_date(date) date.strftime('%e %B %Y') end + + def immich_search_url(base_url, start_date, end_date) + query = { + takenAfter: "#{start_date.to_date}T00:00:00.000Z", + takenBefore: "#{end_date.to_date}T23:59:59.999Z" + } + + encoded_query = URI.encode_www_form_component(query.to_json) + "#{base_url}/search?query=#{encoded_query}" + end end diff --git a/app/views/trips/show.html.erb b/app/views/trips/show.html.erb index 07f2f1e4..76a3a453 100644 --- a/app/views/trips/show.html.erb +++ b/app/views/trips/show.html.erb @@ -65,7 +65,7 @@ <% end %>
- <%= link_to "More photos on Immich", "#", class: "btn btn-primary" %> + <%= link_to "More photos on Immich", immich_search_url(current_user.settings['immich_url'], @trip.started_at, @trip.ended_at), class: "btn btn-primary", target: '_blank' %>