app/helpers/cornell_catalog_helper.rb
# when all items on holding have the same temp location,
# rejigger the temp location to be the
# perm location
when all items on holding have the same temp location,
rejigger the temp location to be the
perm location
when all items on holding have the same temp location rejigger the temp location to be the perm location
def fix_temps(con_full)
	    if @document.nil?
	      iarray = nil
	    else
	      iarray = @document['item_record_display']
	    end
	    items = []
	    if iarray.nil?
	      return con_full
	    end
	    iarray.each do |ite|
	      items << JSON.parse(ite)
	    end
	    cond2 = []
	    con_full.each do |loc|
	      loc2 = loc
	      im = items.select {|i| i['mfhd_id'] == loc['holding_id'][0] }
	      tm = im.select {|i| !i['temp_location']['code'].blank? }
	      tl = (im.select {|i| !i['temp_location']['code'].blank?  }).each{|x| x.keep_if{|k,v| k== 'temp_location'}}
	      if tm.count > 0 and tm.count == im.count
		loc2['location_name'] = tl[0]['temp_location']['name']
		loc2['location_code'] = tl[0]['temp_location']['code']
		loc2['copies'][0].delete('temp_locations')
	      end
	      cond2 << loc2
	    end
	    cond2
	  end
def fix_temps ( con_full ) if @document . nil? iarray = nil else iarray = @document [ 'item_record_display' ] end items = [ ] if iarray . nil? return con_full end iarray . each do | ite | items << JSON . parse ( ite ) end cond2 = [ ] con_full . each do | loc | loc2 = loc im = items . select { | i | i [ 'mfhd_id' ] == loc [ 'holding_id' ] [ 0 ] } tm = im . select { | i | ! i [ 'temp_location' ] [ 'code' ] . blank? } tl = ( im . select { | i | ! i [ 'temp_location' ] [ 'code' ] . blank? } ) . each { | x | x . keep_if { | k , v | k == 'temp_location' } } if tm . count > 0 and tm . count == im . count loc2 [ 'location_name' ] = tl [ 0 ] [ 'temp_location' ] [ 'name' ] loc2 [ 'location_code' ] = tl [ 0 ] [ 'temp_location' ] [ 'code' ] loc2 [ 'copies' ] [ 0 ] . delete ( 'temp_locations' ) end cond2 << loc2 end cond2 end
when all items on holding have the same temp location,
rejigger the temp location to be the
perm location
when all items on holding have the same temp location rejigger the temp location to be the perm location
##Rails.logger.debug "\nes287_debug fix_temp: #{__FILE__} line(#{__LINE__}) con_full=#{con_full.inspect}\n" ##Rails.logger.debug "\nes287_debug fix_temp: #{__FILE__} line(#{__LINE__}) @document.item_record_display=#{@document['item_record_display'].inspect}\n" ##Rails.logger.debug "\nes287_debug fix_temp: #{__FILE__} line(#{__LINE__}) items=#{items}\n" # for each holding record, count the items ##Rails.logger.debug "\nes287_debug #{__FILE__} line(#{__LINE__}) location=#{loc['location_name']} callnumber=#{loc['call_number']} holding_id=#{loc['holding_id'][0]}\n" #select from items array those with matching mfhd_id, and count them. how many items on this mfhd? ##Rails.logger.debug "\nes287_debug #{__FILE__} line(#{__LINE__}) items matching=#{im.inspect} and count for this holding = #{im.count}\n" ##Rails.logger.debug "\nes287_debug #{__FILE__} line(#{__LINE__}) items matching with temp=#{tm.inspect} and count with temps= #{tm.count}\n" ##Rails.logger.debug "\nes287_debug #{__FILE__} line(#{__LINE__}) tl=#{tl.inspect}\n" #select from items array those with matching mfhd_id and a temp loc, and count them. how many items on this mfhd with a temp location? ##Rails.logger.debug "\nes287_debug #{__FILE__} line(#{__LINE__}) loc2=#{loc2.inspect}\n" ##Rails.logger.debug "\nes287_debug #{__FILE__} line(#{__LINE__}) cond2=#{cond2.inspect}\n"
con_full
<not_specific>