Sha256: a331b2651a2ce6b7eeb0151f6788dd014474e64562f3df8aefc77e7fd497f5be

Contents?: true

Size: 1.33 KB

Versions: 16

Compression:

Stored size: 1.33 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|
              job = session.job_group("main").new("update", type: :update, sets: :core)

              entries.each.with_index do |entry, i|
                person = people.find(entry)

                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

16 entries across 16 versions & 1 rubygems

Version Path
eco-helpers-0.6.17 lib/eco/api/usecases/default_cases/set_supervisor_case.rb
eco-helpers-0.6.16 lib/eco/api/usecases/default_cases/set_supervisor_case.rb
eco-helpers-0.6.15 lib/eco/api/usecases/default_cases/set_supervisor_case.rb
eco-helpers-0.6.13 lib/eco/api/usecases/default_cases/set_supervisor_case.rb
eco-helpers-0.6.12 lib/eco/api/usecases/default_cases/set_supervisor_case.rb
eco-helpers-0.6.11 lib/eco/api/usecases/default_cases/set_supervisor_case.rb
eco-helpers-0.6.9 lib/eco/api/usecases/default_cases/set_supervisor_case.rb
eco-helpers-0.6.8 lib/eco/api/usecases/default_cases/set_supervisor_case.rb
eco-helpers-0.6.7 lib/eco/api/usecases/default_cases/set_supervisor_case.rb
eco-helpers-0.6.6 lib/eco/api/usecases/default_cases/set_supervisor_case.rb
eco-helpers-0.6.5 lib/eco/api/usecases/default_cases/set_supervisor_case.rb
eco-helpers-0.6.4 lib/eco/api/usecases/default_cases/set_supervisor_case.rb
eco-helpers-0.6.3 lib/eco/api/usecases/default_cases/set_supervisor_case.rb
eco-helpers-0.6.2 lib/eco/api/usecases/default_cases/set_supervisor_case.rb
eco-helpers-0.6.1 lib/eco/api/usecases/default_cases/set_supervisor_case.rb
eco-helpers-0.6.0 lib/eco/api/usecases/default_cases/set_supervisor_case.rb