class Eco::API::UseCases::DefaultCases::SetSupervisorCase < Eco::API::Common::Loaders::UseCase name "set-supervisor" type :sync def main(entries, people, session, options, usecase) micro = session.micro update = session.new_job("main", "update", :update, usecase) micro.with_each_present(entries, people, options, log_starter: true) do |entry, person| micro.with_supervisor(entry.supervisor_id, people) do |supervisor| if supervisor update.add(person) person.supervisor_id = supervisor.id unless options.dig(:exclude, :supervisor) else unless !entry.supervisor_id session.logger.warn("Supervisor '#{entry.supervisor_id}' does not exist. Entry: #{entry.to_s(:identify)}") end end end end end end