1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-04 21:15:19 +02:00

Show UI warning to user when they need provider data but have not setup Synth yet (#1926)

* Simplify provider concerns

* Update tests

* Add UI warning for missing Synth key if family requires external data
This commit is contained in:
Zach Gollwitzer 2025-02-28 11:35:10 -05:00 committed by GitHub
parent 624faa10d0
commit fa0248056d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 184 additions and 136 deletions

View file

@ -75,10 +75,7 @@ class TradeImport < Import
return internal_security if internal_security.present?
# If security prices provider isn't properly configured or available, create with nil exchange_operating_mic
provider = Security.security_prices_provider
unless provider.present? && provider.respond_to?(:search_securities)
return Security.find_or_create_by!(ticker: ticker, exchange_operating_mic: nil)
end
return Security.find_or_create_by!(ticker: ticker, exchange_operating_mic: nil) unless Security.provider.present?
# Cache provider responses so that when we're looping through rows and importing,
# we only hit our provider for the unique combinations of ticker / exchange_operating_mic
@ -86,18 +83,10 @@ class TradeImport < Import
@provider_securities_cache ||= {}
provider_security = @provider_securities_cache[cache_key] ||= begin
response = provider.search_securities(
Security.search_provider(
query: ticker,
exchange_operating_mic: exchange_operating_mic
)
if !response || !response.success? || !response.securities || response.securities.empty?
nil
else
response.securities.first
end
rescue => e
nil
).first
end
return Security.find_or_create_by!(ticker: ticker, exchange_operating_mic: nil) if provider_security.nil?