From 414321f2cbdb60e635ca9c7a545d04b471eb2cb6 Mon Sep 17 00:00:00 2001 From: jambun Date: Thu, 14 Jul 2016 10:09:38 +1000 Subject: [PATCH] subcontainer types are optional, so left join to keep those rows --- backend/model/trees_mixin.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/model/trees_mixin.rb b/backend/model/trees_mixin.rb index e69fa60..3a2f619 100644 --- a/backend/model/trees_mixin.rb +++ b/backend/model/trees_mixin.rb @@ -84,8 +84,8 @@ def containers_ds TopContainer.linked_instance_ds .join(:archival_object, :id => :instance__archival_object_id) .join(:enumeration_value___top_container_type, :id => :top_container__type_id) - .join(:enumeration_value___sub_container_type_2, :id => :sub_container__type_2_id) - .join(:enumeration_value___sub_container_type_3, :id => :sub_container__type_3_id) + .left_join(:enumeration_value___sub_container_type_2, :id => :sub_container__type_2_id) + .left_join(:enumeration_value___sub_container_type_3, :id => :sub_container__type_3_id) .filter(:archival_object__root_record_id => self.id) .select(Sequel.as(:archival_object__id, :archival_object_id), Sequel.as(:top_container__barcode, :top_container_barcode), @@ -109,10 +109,10 @@ def fetch_container_info row[:top_container_barcode] ? ('[' + row[:top_container_barcode] + ']') : nil].compact.join(': '), # BoxType_2 Indicator_2 - [row[:sub_container_type_2], row[:sub_container_indicator_2]].join(': '), + [row[:sub_container_type_2], row[:sub_container_indicator_2]].compact.join(': '), # BoxType_3 Indicator_3 - [row[:sub_container_type_3], row[:sub_container_indicator_3]].join(': '), + [row[:sub_container_type_3], row[:sub_container_indicator_3]].compact.join(': '), ].reject(&:empty?).join(', ') end