Sha256: 24ceb06ed6658dfd3fef5a12b9c15c39904e3cb4f4749b300cebae58d95e9c74
Contents?: true
Size: 1.99 KB
Versions: 1
Compression:
Stored size: 1.99 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, options| creation = session.job_group("main").new("create", type: :create, sets: [:core, :details]) supers = session.job_group("post").new("supers", type: :update, sets: :core) strict_search = session.config.people.strict_search? || options.dig(:search, :strict) entries.each.with_index do |entry, i| if person = people.find(entry, strict: strict_search) 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
eco-helpers-0.7.1 | lib/eco/api/usecases/default_cases/create_details_with_supervisor_case.rb |