diff --git a/.app_version b/.app_version index af88ba82..bc859cbd 100644 --- a/.app_version +++ b/.app_version @@ -1 +1 @@ -0.11.1 +0.11.2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 28c6d3de..fd3f579c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ 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.11.2] — 2024-08-22 + +### Changed + +### Fixed + +- Dawarich export was failing when attempted to be imported back to Dawarich. +- Imports page with a lot of imports should now load faster. + + ## [0.11.1] — 2024-08-21 ### Changed diff --git a/app/jobs/import_job.rb b/app/jobs/import_job.rb index 2e72f684..a8b449ce 100644 --- a/app/jobs/import_job.rb +++ b/app/jobs/import_job.rb @@ -13,21 +13,11 @@ class ImportJob < ApplicationJob raw_points: result[:raw_points], doubles: result[:doubles], processed: result[:processed] ) - Notifications::Create.new( - user:, - kind: :info, - title: 'Import finished', - content: "Import \"#{import.name}\" successfully finished." - ).call + create_import_finished_notification(import, user) StatCreatingJob.perform_later(user_id) rescue StandardError => e - Notifications::Create.new( - user:, - kind: :error, - title: 'Import failed', - content: "Import \"#{import.name}\" failed: #{e.message}, stacktrace: #{e.backtrace.join("\n")}" - ).call + create_import_failed_notification(import, user, e) end private @@ -43,4 +33,22 @@ class ImportJob < ApplicationJob when 'immich_api' then Immich::ImportParser end end + + def create_import_finished_notification(import, user) + Notifications::Create.new( + user:, + kind: :info, + title: 'Import finished', + content: "Import \"#{import.name}\" successfully finished." + ).call + end + + def create_import_failed_notification(import, user, error) + Notifications::Create.new( + user:, + kind: :error, + title: 'Import failed', + content: "Import \"#{import.name}\" failed: #{error.message}, stacktrace: #{error.backtrace.join("\n")}" + ).call + end end diff --git a/app/models/point.rb b/app/models/point.rb index 64143f18..d048808e 100644 --- a/app/models/point.rb +++ b/app/models/point.rb @@ -3,7 +3,7 @@ class Point < ApplicationRecord reverse_geocoded_by :latitude, :longitude - belongs_to :import, optional: true + belongs_to :import, optional: true, counter_cache: true belongs_to :visit, optional: true belongs_to :user @@ -15,7 +15,7 @@ class Point < ApplicationRecord report_location_message_event: 4, manual_event: 5, timer_based_event: 6, settings_monitoring_event: 7 }, _suffix: true - enum connection: { mobile: 0, wifi: 1, offline: 2 }, _suffix: true + enum connection: { mobile: 0, wifi: 1, offline: 2, unknown: 4 }, _suffix: true scope :reverse_geocoded, -> { where.not(geodata: {}) } scope :not_reverse_geocoded, -> { where(geodata: {}) } diff --git a/app/services/exports/create.rb b/app/services/exports/create.rb index f835116b..0024aa6c 100644 --- a/app/services/exports/create.rb +++ b/app/services/exports/create.rb @@ -11,11 +11,11 @@ class Exports::Create def call export.update!(status: :processing) - pp "====Exporting data for #{user.email} from #{start_at} to #{end_at}" + Rails.logger.debug "====Exporting data for #{user.email} from #{start_at} to #{end_at}" points = time_framed_points - pp "====Exporting #{points.size} points" + Rails.logger.debug "====Exporting #{points.size} points" data = ::ExportSerializer.new(points, user.email).call file_path = Rails.root.join('public', 'exports', "#{export.name}.json") @@ -24,21 +24,11 @@ class Exports::Create export.update!(status: :completed, url: "exports/#{export.name}.json") - Notifications::Create.new( - user:, - kind: :info, - title: 'Export finished', - content: "Export \"#{export.name}\" successfully finished." - ).call + create_export_finished_notification rescue StandardError => e Rails.logger.error("====Export failed to create: #{e.message}") - Notifications::Create.new( - user:, - kind: :error, - title: 'Export failed', - content: "Export \"#{export.name}\" failed: #{e.message}, stacktrace: #{e.backtrace.join("\n")}" - ).call + create_failed_export_notification(e) export.update!(status: :failed) end @@ -50,7 +40,24 @@ class Exports::Create def time_framed_points user .tracked_points - .without_raw_data .where('timestamp >= ? AND timestamp <= ?', start_at.to_i, end_at.to_i) end + + def create_export_finished_notification + Notifications::Create.new( + user:, + kind: :info, + title: 'Export finished', + content: "Export \"#{export.name}\" successfully finished." + ).call + end + + def create_failed_export_notification(error) + Notifications::Create.new( + user:, + kind: :error, + title: 'Export failed', + content: "Export \"#{export.name}\" failed: #{error.message}, stacktrace: #{error.backtrace.join("\n")}" + ).call + end end diff --git a/app/views/imports/index.html.erb b/app/views/imports/index.html.erb index c0bee84e..69af4ac8 100644 --- a/app/views/imports/index.html.erb +++ b/app/views/imports/index.html.erb @@ -46,7 +46,7 @@ <%= link_to import.name, import, class: 'underline hover:no-underline' %> (<%= import.source %>)