MAX_GET_PARTIAL = 12_000 ASSETS.cli.config do |cnf| cnf.people do |input, session, options| get = options.dig(:people, :get) get = {} if get.nil? from_remote = get && get[:from] == :remote from_local = get && get[:from] == :local get_full = from_remote && get[:type] == :full get_partial = from_remote && get[:type] == :partial get_by_file = from_local && get[:type] == :file # -get-partial: validate input present and under max if get_partial msg = "To use -get-partial (partial updates), you need to use -entries-from" raise msg unless input.is_a?(Enumerable) if input.count > MAX_GET_PARTIAL get_full = true get_partial = false msg = "(Optimization) " msg << "Switching from partial to full people download. " msg << "Input (#{input.count}) surpases MAX_GET_PARTIAL " msg << "(#{MAX_GET_PARTIAL}) entries." session.log(:info) { msg } options.deep_merge!(people: { get: { from: :remote, type: :full } }) end end if get == false Eco::API::Organization::People.new([]) elsif get_full # -get-people session.micro.people_cache elsif get_partial # -get-partial session.micro.people_search(input, options: options) elsif get_by_file # -people-from-backup session.micro.people_load(get[:file], modifier: :file) else options.deep_merge!(people: { get: { from: :local, type: :full } }) people = session.micro.people_load(modifier: %i[newest save]) if people.empty? options.deep_merge!(people: { get: { from: :remote, type: :full } }) people = session.micro.people_cache end people end end end