Sha256: 065b6fe4fea6ad5443267025f0e3e6bf72dce7769bf770eb6b0e5bde6f4f129a
Contents?: true
Size: 1.49 KB
Versions: 5
Compression:
Stored size: 1.49 KB
Contents
module Eco module API module UseCases class DefaultCases class SetSupervisorCase < BaseCase def process @cases.define("set-supervisor", type: :sync) do |entries, people, session, options| job = session.job_group("main").new("update", 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
5 entries across 5 versions & 1 rubygems