Fix in memory loading of storage location tree [SCI-10863]

This commit is contained in:
Andrej 2024-07-23 09:44:57 +02:00
parent 2f53772f61
commit d725e278c1

View file

@ -142,17 +142,11 @@ class StorageLocationsController < ApplicationController
}
end
def storage_locations_recursive_builder(storage_location, records)
children = records.select do |i|
defined?(i.parent_id) && i.parent_id == storage_location&.id
end
children.filter_map do |i|
next if i.container
def storage_locations_recursive_builder(parent_storage_location, records)
records.where(parent: parent_storage_location, container: false).map do |storage_location|
{
storage_location: i,
children: storage_locations_recursive_builder(i, records)
storage_location: storage_location,
children: storage_locations_recursive_builder(storage_location, records)
}
end
end