Skip to content

Commit

Permalink
return nil for date sort by default, an empty string was causing an i…
Browse files Browse the repository at this point in the history
…ndexing error
  • Loading branch information
mejackreed committed Feb 5, 2018
1 parent de5bce8 commit f060ab4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/concerns/mods_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def mods_to_solr
# 7. Partial date ["June 1781"] (eg: zq824dz1346)
# 8. Approximate start and end years ["s. XIII^^ex [ca. 1275-1300]"] (eg: rc145sy7436)
def parse_dates(input_dates)
dates = { all_int: [], sort: '' }
dates = { all_int: [], sort: nil }
return dates if input_dates.blank?
input_dates.each do |dt|
dates[:all_int] << dt.to_s.scan(/[0-9]{3,4}/)
Expand All @@ -141,6 +141,7 @@ def parse_dates(input_dates)
end
dates[:all_int].flatten!
unless dates[:all_int].blank?
dates[:sort] = ''
dates[:all_int] = dates[:all_int].map(&:to_i)
dates[:sort] = (dates[:all_int].inject { |sum, x| sum + x }) / dates[:all_int].length
end
Expand Down

0 comments on commit f060ab4

Please sign in to comment.