Sha256: 8b319d6c3279acbc426d11f393cdb4a7eed4046f382d1f698efdb4fcbab71ee5
Contents?: true
Size: 1.52 KB
Versions: 50
Compression:
Stored size: 1.52 KB
Contents
module Eco module API class UseCases class DefaultCases class SetSupervisorCase < DefaultCase def process @cases.define("set-supervisor", type: :sync) do |entries, people, session, options, usecase| job = session.job_group("main").new("update", usecase: usecase, type: :update, sets: :core) strict_search = session.config.people.strict_search? && (!options[:search]&.key?(:strict) || options.dig(:search, :strict)) entries.each.with_index do |entry, i| person = people.find(entry, strict: strict_search) if !person session.logger.error("Entry(#{i}) - this person does not exist: #{entry.to_s(:identify)}") else sup_id = entry.supervisor_id supervisor = people.person(id: sup_id, external_id: sup_id, email: sup_id) if !supervisor if entry.supervisor_id msg = "Entry(#{i}) - supervisor id #{entry.supervisor_id} does not exist for person: #{entry.to_s(:identify)}" session.logger.warn(msg) end else # set internal id of the supervisor (detect if actually changed) person.supervisor_id = supervisor.id job.add(person) end end end end end end end end end end
Version data entries
50 entries across 50 versions & 1 rubygems