1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-27 17:19:39 +02:00

Fix sync error when security missing

This commit is contained in:
Zach Gollwitzer 2024-12-02 10:53:16 -05:00
parent c3248cd796
commit d592495be5
3 changed files with 10 additions and 6 deletions

View file

@ -158,19 +158,21 @@ class PlaidAccount < ApplicationRecord
end end
def get_security(plaid_security, securities) def get_security(plaid_security, securities)
security = nil return nil if plaid_security.nil?
if plaid_security.ticker_symbol.present? security = if plaid_security.ticker_symbol.present?
security = plaid_security plaid_security
else 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 end
return nil if security.nil? || security.ticker_symbol.blank?
Security.find_or_create_by!( Security.find_or_create_by!(
ticker: security.ticker_symbol, ticker: security.ticker_symbol,
exchange_mic: security.market_identifier_code || "XNAS", exchange_mic: security.market_identifier_code || "XNAS",
country_code: "US" country_code: "US"
) if security.present? )
end end
def transfer?(plaid_txn) def transfer?(plaid_txn)

View file

@ -29,6 +29,7 @@ class Sync < ApplicationRecord
end end
def fail!(error) def fail!(error)
Sentry.capture_exception(error)
update! status: :failed, error: error.message, last_ran_at: Time.current update! status: :failed, error: error.message, last_ran_at: Time.current
end end
end end

View file

@ -1,8 +1,9 @@
if ENV["SENTRY_DSN"].present? if ENV["SENTRY_DSN"].present?
Sentry.init do |config| Sentry.init do |config|
config.dsn = ENV["SENTRY_DSN"] config.dsn = ENV["SENTRY_DSN"]
config.environment = ENV["RAILS_ENV"]
config.breadcrumbs_logger = [ :active_support_logger, :http_logger ] 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% # Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring. # of transactions for performance monitoring.