Sha256: 00124f8d8c4d01f62d04f773be8063b265f1d001f55cac479a12c5a69c2ae3f9
Contents?: true
Size: 1.86 KB
Versions: 16
Compression:
Stored size: 1.86 KB
Contents
module Eco module API module UseCases class DefaultCases class CreateDetailsWithSupervisorCase < UseCases::BaseCase def process # good candidate to do @cases.case("create-details").use.chain(@cases.case("set-supervisor").use) @cases.define("create-details-with-supervisor", type: :sync) do |entries, people, session| creation = session.job_group("main").new("create", type: :create, sets: [:core, :details]) supers = session.job_group("post").new("supers", type: :update, sets: :core) entries.each.with_index do |entry, i| if person = people.find(entry) session.logger.error("Entry(#{i}) - this person (id: '#{person.id}') already exists: #{entry.to_s(:identify)}") else person = session.new_person entry.set_core(person, exclude: "supervisor_id") entry.set_details(person) creation.add(person) # set supervisor if !(sup_id = entry.supervisor_id) person.supervisor_id = nil else if supervisor = people.person(id: sup_id, external_id: sup_id, email: sup_id) person.supervisor_id = supervisor.id else # delay setting supervisor if does not exit supers.add(person) do |person| #person = session.new_person(person: person.doc) person.sync person.supervisor_id = sup_id person end end end end end end end end end end end end
Version data entries
16 entries across 16 versions & 1 rubygems