diff --git a/backend/model/do_report.rb b/backend/model/do_report.rb index 39d91bf..52db926 100644 --- a/backend/model/do_report.rb +++ b/backend/model/do_report.rb @@ -6,30 +6,30 @@ class DOReport attr_reader :items BASE_COLUMNS = [ - {:header => "Resource ID", :proc => Proc.new {|resource, item| resource_id(resource)}}, - {:header => "Ref ID", :proc => Proc.new {|resource, item| ref_id(item)}}, - {:header => "URI", :proc => Proc.new {|resource, item| record_uri(item)}}, - {:header => "Indicator 1", :proc => Proc.new {|resource, item, dates, box| indicator_1(box)}}, - {:header => "Indicator 2", :proc => Proc.new {|resource, item, dates, box| indicator_2(box)}}, - {:header => "Indicator 3", :proc => Proc.new {|resource, item, dates, box| indicator_3(box)}}, - {:header => "Title", :proc => Proc.new {|resource, item| record_title(item)}}, - {:header => "Component ID", :proc => Proc.new {|resource, item| component_id(item)}}, + {:header => "Resource ID", :proc => Proc.new {|resource, item| resource_id(resource)}}, + {:header => "Ref ID", :proc => Proc.new {|resource, item| ref_id(item)}}, + {:header => "URI", :proc => Proc.new {|resource, item| record_uri(item)}}, + {:header => "Container Indicator 1", :proc => Proc.new {|resource, item, dates, box| indicator_1(box)}}, + {:header => "Container Indicator 2", :proc => Proc.new {|resource, item, dates, box| indicator_2(box)}}, + {:header => "Container Indicator 3", :proc => Proc.new {|resource, item, dates, box| indicator_3(box)}}, + {:header => "Title", :proc => Proc.new {|resource, item| record_title(item)}}, + {:header => "Component ID", :proc => Proc.new {|resource, item| component_id(item)}}, ] SERIES_COLUMNS = [ - {:header => "Series", :proc => Proc.new { |resource, item, dates, box, series| record_title(series) }} + {:header => "Series", :proc => Proc.new { |resource, item, dates, box, series| record_title(series) }} ] SUBSERIES_COLUMNS = [ - {:header => "Sub-Series", :proc => Proc.new { |resource, item, dates, box, series, subseries| record_title(subseries) }} + {:header => "Sub-Series", :proc => Proc.new { |resource, item, dates, box, series, subseries| record_title(subseries) }} ] BARCODE_COLUMNS = [ - {:header => "Barcode", :proc => Proc.new {|resource, item, dates, box| barcode(box)}} + {:header => "Barcode", :proc => Proc.new {|resource, item, dates, box| barcode(box)}} ] DATES_COLUMNS = [ - {:header => "Dates", :proc => Proc.new {|resource, item, dates| date_string(dates)}} + {:header => "Dates", :proc => Proc.new {|resource, item, dates| date_string(dates)}} ] @@ -240,31 +240,30 @@ def self.ref_id(item) end - def self.indicator_1(box) + def self.box_concat(box, &block) return '' unless box - if box[:top_container] - box[:top_container][:indicator] - end + out = box.map { |b| block.call(b) } + out.compact.join(', ') + end + + + def self.indicator_1(box) + box_concat(box) { |b| b[:top_container][:indicator] if b[:top_container] } end def self.barcode(box) - return '' unless box - if box[:top_container] - box[:top_container][:barcode] - end + box_concat(box) { |b| b[:top_container][:barcode] if b[:top_container] } end def self.indicator_2(box) - return '' unless box - box[:sub_container][:indicator_2] + box_concat(box) { |b| b[:sub_container][:indicator_2] } end def self.indicator_3(box) - return '' unless box - box[:sub_container][:indicator_3] + box_concat(box) { |b| b[:sub_container][:indicator_3] } end diff --git a/backend/model/trees_mixin.rb b/backend/model/trees_mixin.rb index 3a2f619..9f58b3e 100644 --- a/backend/model/trees_mixin.rb +++ b/backend/model/trees_mixin.rb @@ -71,8 +71,8 @@ def quick_containers :type_3 => row[:sub_container_type_3], :indicator_3 => row[:sub_container_indicator_3], } - result[row[:archival_object_id]] = fields - + result[row[:archival_object_id]] ||= [] + result[row[:archival_object_id]] << fields end result end @@ -83,7 +83,7 @@ def quick_containers 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) + .left_join(:enumeration_value___top_container_type, :id => :top_container__type_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)