app/models/manager_refresh/inventory_collection.rb
def extract_references(new_references = [])
      # We collect what manager_uuids of this IC were referenced and we load only those
      # TODO(lsmola) maybe in can be obj[x] = Set.new, since rails will do a query "col1 IN [a,b,b] AND col2 IN [e,f,e]"
      # which is equivalent to "col1 IN [a,b] AND col2 IN [e,f]". The best would be to forcing rails to query
      # "(col1, col2) IN [(a,e), (b,f), (b,e)]" which would load exactly what we need. Postgree supports this, but rails
      # doesn't seem to. So for now, we can load a bit more from the DB than we need, in case of manager_ref.count > 1
      hash_uuids_by_ref = manager_ref.each_with_object({}) { |x, obj| obj[x] = [] }

      # TODO(lsmola) hm, if we call find in the parser code, not all references will be here, so this will really work
      # only for lazy_find. So if we want to call find, I suppose we can cache all, possibly we could optimize this to
      # set references upfront?
      new_references.each do |reference|
        refs = reference.split(stringify_joiner)

        refs.each_with_index do |ref, index|
          hash_uuids_by_ref[manager_ref[index]] << ref
        end
      end
      hash_uuids_by_ref
    end
# Extracting references to a relation friendly format, or a format processable by a custom_db_finder
#
# @param new_references [Array] array of manager_uuids of the InventoryObjects
Extracting references to a relation friendly format, or a format processable by a custom_db_finder
Extracting references to a relation friendly format or a format processable by a custom_db_finder
def extract_references(new_references = [])
      hash_uuids_by_ref = manager_ref.each_with_object({}) { |x, obj| obj[x] = [] }
      new_references.each do |reference|
        refs = reference.split(stringify_joiner)
        refs.each_with_index do |ref, index|
          hash_uuids_by_ref[manager_ref[index]] << ref
        end
      end
      hash_uuids_by_ref
    end
def extract_references ( new_references = [ ] ) hash_uuids_by_ref = manager_ref . each_with_object ( { } ) { | x , obj | obj [ x ] = [ ] } new_references . each do | reference | refs = reference . split ( stringify_joiner ) refs . each_with_index do | ref , index | hash_uuids_by_ref [ manager_ref [ index ] ] << ref end end hash_uuids_by_ref end
Extracting references to a relation friendly format, or a format processable by a custom_db_finder
Extracting references to a relation friendly format or a format processable by a custom_db_finder
# We collect what manager_uuids of this IC were referenced and we load only those # TODO(lsmola) maybe in can be obj[x] = Set.new, since rails will do a query "col1 IN [a,b,b] AND col2 IN [e,f,e]" # which is equivalent to "col1 IN [a,b] AND col2 IN [e,f]". The best would be to forcing rails to query # "(col1, col2) IN [(a,e), (b,f), (b,e)]" which would load exactly what we need. Postgree supports this, but rails # doesn't seem to. So for now, we can load a bit more from the DB than we need, in case of manager_ref.count > 1 # TODO(lsmola) hm, if we call find in the parser code, not all references will be here, so this will really work # only for lazy_find. So if we want to call find, I suppose we can cache all, possibly we could optimize this to # set references upfront?
new_references
array of manager_uuids of the InventoryObjects
array of manager_uuids of the InventoryObjects