Skip to content

Commit

Permalink
Fix sync error when security missing
Browse files Browse the repository at this point in the history
  • Loading branch information
zachgoll committed Dec 2, 2024
1 parent c3248cd commit d592495
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
12 changes: 7 additions & 5 deletions app/models/plaid_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,21 @@ def family
end

def get_security(plaid_security, securities)
security = nil
return nil if plaid_security.nil?

if plaid_security.ticker_symbol.present?
security = plaid_security
security = if plaid_security.ticker_symbol.present?
plaid_security
else
security = securities.find { |s| s.security_id == plaid_security.proxy_security_id }
securities.find { |s| s.security_id == plaid_security.proxy_security_id }
end

return nil if security.nil? || security.ticker_symbol.blank?

Security.find_or_create_by!(
ticker: security.ticker_symbol,
exchange_mic: security.market_identifier_code || "XNAS",
country_code: "US"
) if security.present?
)
end

def transfer?(plaid_txn)
Expand Down
1 change: 1 addition & 0 deletions app/models/sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def complete!
end

def fail!(error)
Sentry.capture_exception(error)
update! status: :failed, error: error.message, last_ran_at: Time.current
end
end
3 changes: 2 additions & 1 deletion config/initializers/sentry.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
if ENV["SENTRY_DSN"].present?
Sentry.init do |config|
config.dsn = ENV["SENTRY_DSN"]
config.environment = ENV["RAILS_ENV"]
config.breadcrumbs_logger = [ :active_support_logger, :http_logger ]
config.enabled_environments = %w[production]
config.enabled_environments = %w[development production]

# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
Expand Down

0 comments on commit d592495

Please sign in to comment.