Skip to content

Commit

Permalink
make sure webs_to_es fields can handle nil values
Browse files Browse the repository at this point in the history
  • Loading branch information
wkdewey committed Feb 28, 2023
1 parent 9b8748a commit d4a8144
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/datura/to_es/webs_to_es/fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ def data_type
end

def date(before=true)
datestr = get_list(@xpaths["date"]).first
if get_list(@xpaths["date"])
datestr = get_list(@xpaths["date"]).first
else
datestr = nil
end
if datestr
Datura::Helpers.date_standardize(datestr, true)
end
Expand Down Expand Up @@ -80,7 +84,9 @@ def format
end

def image_id
get_list(@xpaths["image_id"]).first
if get_list(@xpaths["image_id"])
get_list(@xpaths["image_id"]).first
end
end

def keywords
Expand Down Expand Up @@ -218,7 +224,9 @@ def works
# new/moved fields for API 2.0

def cover_image
get_list(@xpaths["image_id"]).first
if get_list(@xpaths["image_id"])
get_list(@xpaths["image_id"]).first
end
end

def date_updated
Expand Down

0 comments on commit d4a8144

Please sign in to comment.