lib/eco/api/usecases/graphql/helpers/location/base.rb in eco-helpers-2.5.4 vs lib/eco/api/usecases/graphql/helpers/location/base.rb in eco-helpers-2.5.5

- old
+ new

@@ -66,11 +66,11 @@ return @target_structure_id if @target_structure_id msg = "Const TARGET_STRUCTURE_ID has not been defined, " msg << "nor options(:source, :structure_id). " msg << "Infering active locations structure." log(:warn) { msg } - if self.current_tree = session.live_tree + if self.current_tree = session_live_tree @target_structure_id = current_tree.id end end # Retrieves the live tree only if `current_tree` hasn't been just retrieved. @@ -79,9 +79,15 @@ # prevent unnecessary requests. def live_tree tree_init = current_tree target_id = target_structure_id return current_tree if current_tree != tree_init - self.current_tree = session.live_tree(id: target_id, include_archived: true) + self.current_tree = session_live_tree(id: target_id) + end + + # Unique access point to retrieve the live tree + # @note ensures archived nodes are retrieved. + def session_live_tree(id: nil) + session.live_tree(id: id, include_archived: true) end end end