From 609688f14459d855cc9d29c2fba33ea1dc033cf0 Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Tue, 29 Oct 2024 11:09:58 +0100 Subject: [PATCH] Write Immich debug data and fix Sidekiq healthcheck --- .app_version | 2 +- CHANGELOG.md | 19 +++++++++++++++++++ app/services/immich/import_geodata.rb | 15 +++++++++++++-- docker-compose.yml | 2 +- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/.app_version b/.app_version index 8b7217f9..e78439d7 100644 --- a/.app_version +++ b/.app_version @@ -1 +1 @@ -0.15.10 +0.15.11 diff --git a/CHANGELOG.md b/CHANGELOG.md index 000b5896..7d42d073 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +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.15.11 - 2024-10-29 + +### Added + +- Importing Immich data on the Imports page now will trigger an attempt to write raw json file with the data from Immich to `tmp/imports/immich_raw_data_CURRENT_TIME_USER_EMAIL.json` file. This is useful to debug the problem with the import if it fails. #270 + +### Changed + +- Hostname definition for Sidekiq healtcheck to solve #344. See the diff: + +```diff + dawarich_sidekiq: + image: freikin/dawarich:latest + container_name: dawarich_sidekiq + healthcheck: +- test: [ "CMD-SHELL", "bundle exec sidekiqmon processes | grep $(hostname)" ] ++ test: [ "CMD-SHELL", "bundle exec sidekiqmon processes | grep ${HOSTNAME}" ] +``` + # 0.15.10 - 2024-10-25 ### Fixed diff --git a/app/services/immich/import_geodata.rb b/app/services/immich/import_geodata.rb index af59fdb5..80a47cfd 100644 --- a/app/services/immich/import_geodata.rb +++ b/app/services/immich/import_geodata.rb @@ -13,7 +13,12 @@ class Immich::ImportGeodata raise ArgumentError, 'Immich API key is missing' if immich_api_key.blank? raise ArgumentError, 'Immich URL is missing' if user.settings['immich_url'].blank? - immich_data = retrieve_immich_data + immich_data = retrieve_immich_data + + log_no_data and return if immich_data.empty? + + write_raw_data(immich_data) + immich_data_json = parse_immich_data(immich_data) file_name = file_name(immich_data_json) import = user.imports.find_or_initialize_by(name: file_name, source: :immich_api) @@ -35,7 +40,7 @@ class Immich::ImportGeodata end def retrieve_immich_data - 1970.upto(Date.today.year).flat_map do |year| + 1970.upto(Time.zone.today.year).flat_map do |year| (1..12).map do |month_number| url = "#{immich_api_base_url}/timeline/bucket?size=MONTH&timeBucket=#{year}-#{month_number}-01" @@ -72,6 +77,12 @@ class Immich::ImportGeodata Rails.logger.debug 'No data found' end + def write_raw_data(immich_data) + File.open("tmp/imports/immich_raw_data_#{Time.current}_#{user.email}.json", 'w') do |file| + file.write(immich_data.to_json) + end + end + def create_import_failed_notification(import_name) Notifications::Create.new( user:, diff --git a/docker-compose.yml b/docker-compose.yml index f51c1ee0..537b7444 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -121,7 +121,7 @@ services: max-size: "100m" max-file: "5" healthcheck: - test: [ "CMD-SHELL", "bundle exec sidekiqmon processes | grep $(hostname)" ] + test: [ "CMD-SHELL", "bundle exec sidekiqmon processes | grep ${HOSTNAME}" ] interval: 10s retries: 5 start_period: 30s