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 Jan 26, 2023
1 parent 9b8748a commit 6d90c8e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 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 @@ -218,7 +222,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 6d90c8e

Please sign in to comment.