mirror of
https://github.com/we-promise/sure.git
synced 2026-04-17 02:54:10 +00:00
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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user