From 6d90c8e0f9fe51c65011fd9ab57cb318f93ecaa1 Mon Sep 17 00:00:00 2001 From: William Dewey Date: Wed, 25 Jan 2023 12:44:34 -0600 Subject: [PATCH] make sure webs_to_es fields can handle nil values --- lib/datura/to_es/webs_to_es/fields.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/datura/to_es/webs_to_es/fields.rb b/lib/datura/to_es/webs_to_es/fields.rb index 3163706be..ee7892fc4 100644 --- a/lib/datura/to_es/webs_to_es/fields.rb +++ b/lib/datura/to_es/webs_to_es/fields.rb @@ -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 @@ -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