Remove SimpleFIN sync errors modal and related routes, methods, and logic. (#365)

- Removed the `errors` modal and its associated view.
- Eliminated references to `errors` route and controller methods.
- Consolidated error handling into the `register_error` method to improve error tracking and de-duplication.
- Enhanced logging and introduced instrumentation for better observability.

Co-authored-by: Josh Waldrep <joshua.waldrep5+github@gmail.com>
This commit is contained in:
LPW
2025-11-22 08:08:43 -05:00
committed by GitHub
parent f491916411
commit 3fe9768d72
6 changed files with 92 additions and 129 deletions

View File

@@ -1,6 +1,6 @@
class SimplefinItemsController < ApplicationController
include SimplefinItems::MapsHelper
before_action :set_simplefin_item, only: [ :show, :edit, :update, :destroy, :sync, :balances, :setup_accounts, :complete_account_setup, :errors ]
before_action :set_simplefin_item, only: [ :show, :edit, :update, :destroy, :sync, :balances, :setup_accounts, :complete_account_setup ]
def index
@simplefin_items = Current.family.simplefin_items.active.ordered
@@ -366,35 +366,6 @@ class SimplefinItemsController < ApplicationController
end
end
def errors
# Find the latest sync to surface its error messages in a lightweight modal
latest_sync = if @simplefin_item.syncs.loaded?
@simplefin_item.syncs.max_by(&:created_at)
else
@simplefin_item.syncs.ordered.first
end
stats = (latest_sync&.sync_stats || {})
raw_errors = Array(stats["errors"]) # may contain strings or hashes with message keys
@errors = raw_errors.map { |e|
if e.is_a?(Hash)
e["message"] || e[:message] || e.to_s
else
e.to_s
end
}.compact
# Fall back to simplefin_item.sync_error if present and not already included
if @simplefin_item.respond_to?(:sync_error) && @simplefin_item.sync_error.present?
@errors << @simplefin_item.sync_error
end
# De-duplicate and keep non-empty messages
@errors = @errors.map(&:to_s).map(&:strip).reject(&:blank?).uniq
render layout: false
end
private