Files

31 lines
1.1 KiB
Ruby
Raw Permalink Normal View History

2026-04-17 15:35:10 -04:00
module AutomationService
class BatchEmployerUpdate
2026-05-06 13:28:16 -04:00
def initialize(pl_plan_keys = nil, full_sync = false)
2026-04-17 15:35:10 -04:00
@pl_plan_keys = pl_plan_keys
2026-05-06 13:28:16 -04:00
@full_sync = full_sync
2026-04-17 15:35:10 -04:00
end
def call
sql_query = "SELECT PLPlanKey, PlanId, ShortDesc FROM PLPlanHeader
2026-04-20 12:12:52 -04:00
WHERE ActiveInactive = 'Active'"
if @pl_plan_keys.present?
sql_query = sql_query.concat(" AND PLPlanKey IN (#{@pl_plan_keys.join(',')})")
end
2026-04-17 15:35:10 -04:00
employer_plan_headers = VhcsRecord.connection.select_all(sql_query)
employer_update_futures = employer_plan_headers.map do |employer_plan_header|
Concurrent::Future.execute do
ActiveRecord::Base.connection_pool.with_connection do
2026-05-06 13:28:16 -04:00
UpdateEmployerJob.perform_later(employer_plan_header: employer_plan_header, full_sync: @full_sync)
2026-04-17 15:35:10 -04:00
end
end
end
employer_update_futures.map(&:value)
end
end
end
# AutomationService::MemberUpdate('13', 337710)