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 25, 2023
1 parent d7ab758 commit aff42a2
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 aff42a2

Please sign in to comment.