2024-10-30 18:08:19 -04:00
|
|
|
class FetchSecurityInfoJob < ApplicationJob
|
2025-03-19 12:36:16 -04:00
|
|
|
queue_as :low_priority
|
2024-10-30 18:08:19 -04:00
|
|
|
|
|
|
|
def perform(security_id)
|
2025-02-28 11:35:10 -05:00
|
|
|
return unless Security.provider.present?
|
2024-10-30 18:08:19 -04:00
|
|
|
|
|
|
|
security = Security.find(security_id)
|
|
|
|
|
2025-02-11 10:40:30 -06:00
|
|
|
params = {
|
|
|
|
ticker: security.ticker
|
|
|
|
}
|
|
|
|
params[:mic_code] = security.exchange_mic if security.exchange_mic.present?
|
|
|
|
params[:operating_mic] = security.exchange_operating_mic if security.exchange_operating_mic.present?
|
|
|
|
|
2025-02-28 11:35:10 -05:00
|
|
|
security_info_response = Security.provider.fetch_security_info(**params)
|
2024-10-30 18:08:19 -04:00
|
|
|
|
|
|
|
security.update(
|
2024-11-07 11:52:16 -06:00
|
|
|
name: security_info_response.info.dig("name")
|
2024-10-30 18:08:19 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|