Skip to content

Commit

Permalink
Merge pull request #69 from cul-it/dev
Browse files Browse the repository at this point in the history
Merge changes for v1.2.5
  • Loading branch information
Baroquem authored Aug 9, 2016
2 parents 78cb5db + 1af7f17 commit 2ad5ef0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
41 changes: 25 additions & 16 deletions app/models/blacklight_cornell_requests/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def get_holdings document
exclude_location_list = Array.new

if location_seen[location] == 1
circ_group_id = Circ_policy_locs.select('CIRC_GROUP_ID').where( 'location_id' => location )
circ_group_id = Circ_policy_locs.select('CIRC_GROUP_ID').where( 'LOCATION_ID' => location )

## handle exceptions
## group id 3 - Olin
Expand Down Expand Up @@ -519,7 +519,7 @@ def get_holdings document
end

# logger.debug "sk274_log: circ group id: " + circ_group_id.inspect
locs = Circ_policy_locs.select('location_id').where( :circ_group_id => circ_group_id, :pickup_location => 'Y' )
locs = Circ_policy_locs.select('LOCATION_ID').where( :circ_group_id => circ_group_id, :pickup_location => 'Y' )
locs.each do |loc|
exclude_location_list.push loc['LOCATION_ID']
end
Expand Down Expand Up @@ -650,10 +650,12 @@ def get_delivery_options item
end

# Get delivery time estimates for each option
options.each do |option|
#Rails.logger.debug "es287_log :#{__FILE__}:#{__LINE__} get_option_time.."+ Time.new.inspect
option[:estimate] = get_delivery_time(option[:service], option)
option[:iid] = item
if options.present?
options.each do |option|
#Rails.logger.debug "es287_log :#{__FILE__}:#{__LINE__} get_option_time.."+ Time.new.inspect
option[:estimate] = get_delivery_time(option[:service], option)
option[:iid] = item
end
end

# Rails.logger.info "sk274_log: #{options.inspect}"
Expand Down Expand Up @@ -693,9 +695,16 @@ def get_location(item)

end

# TODO: is 88 the only location for music?
def at_music_library?(item)
%w[88 90 91 92 93 179].include? get_location(item)
# Determine whether an item at the library and can be requested
def music_library_requestable?(item)
# 2 conditions: item is at the music library, and item type is book or music (3 or 5)
# bit hacky: return true if item is *not* at the music library (i.e., for everything
# else being tested here)
if %w[88 90 91 92 93 179].include?(get_location(item))
return [3, 5].include?(item['item_type_id'].to_i)
else # if *not* at the Music library
return true
end
end

# Test for new item type, "unbound" (#39). Can do hold and recall, but not L2L
Expand Down Expand Up @@ -735,15 +744,15 @@ def get_cornell_delivery_options item
:location => item[:location]})
elsif item_loan_type == 'regular' &&
item[:status] == NOT_CHARGED &&
!at_music_library?(item) &&
music_library_requestable?(item) &&
!unbound_type?(typeCode)
request_options.push({:service => L2L,
:location => item[:location] } )
elsif item_loan_type == 'regular' &&
item[:status] == CHARGED
request_options.push({:service => ILL,
:location => item[:location]})
unless at_music_library?(item)
if music_library_requestable?(item)
request_options.push({:service => RECALL,
:location => item[:location]},
{:service => HOLD,
Expand All @@ -752,7 +761,7 @@ def get_cornell_delivery_options item
end
elsif item_loan_type == 'regular' &&
[IN_TRANSIT_DISCHARGED, IN_TRANSIT_ON_HOLD].include?(item[:status]) &&
!at_music_library?(item)
music_library_requestable?(item)
request_options.push({:service => RECALL,
:location => item[:location]},
{:service => HOLD,
Expand All @@ -767,7 +776,7 @@ def get_cornell_delivery_options item
item[:status] == CHARGED
request_options.push({:service => ILL,
:location => item[:location] })
unless at_music_library?(item)
if music_library_requestable?(item)
request_options.push({:service => HOLD,
:location => item[:location],
:status => item[:status] })
Expand All @@ -776,7 +785,7 @@ def get_cornell_delivery_options item
item[:status] == NOT_CHARGED
if Request.no_l2l_day_loan_types.include? typeCode
#return request_options
elsif !at_music_library?(item) &&
elsif music_library_requestable?(item) &&
!unbound_type?(item)
request_options.push( {:service => L2L,
:location => item[:location] } )
Expand All @@ -801,8 +810,8 @@ def get_guest_delivery_options item
if noncirculating? item
[]
elsif item[:status] == NOT_CHARGED && (item_loan_type == 'regular' || item_loan_type == 'day')
[ { :service => L2L, :location => item[:location] } ] unless (no_l2l_day_loan_types?(item_loan_type) || at_music_library?(item) || unbound_type?(typeCode))
elsif item[:status] == CHARGED && (item_loan_type == 'regular' || item_loan_type == 'day') && !at_music_library?(item)
[ { :service => L2L, :location => item[:location] } ] unless (no_l2l_day_loan_types?(item_loan_type) || !music_library_requestable?(item) || unbound_type?(typeCode))
elsif item[:status] == CHARGED && (item_loan_type == 'regular' || item_loan_type == 'day') && music_library_requestable?(item)
[ { :service => HOLD, :location => item[:location], :status => item[:itemStatus] } ]
elsif item_loan_type == 'minute' && (item[:status] == NOT_CHARGED || item[:status] == CHARGED)
[ { :service => ASK_CIRCULATION, :location => item[:location] } ]
Expand Down
7 changes: 7 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Release Notes - blacklight-cornell-requests

## v1.2.5

### Bug fixes
- Fixed a bug that caused a fatal error if no request options were available for an item
- Fixed a bug in the circ policy database query
- Fixed a bug that made books and recordings at Music unrequestable

## v1.2.4

### Enhancements
Expand Down

0 comments on commit 2ad5ef0

Please sign in to comment.