From d9bfe4d15d6132b08c189ca40203bec469df1f7b Mon Sep 17 00:00:00 2001 From: Richard Hallett Date: Fri, 22 Oct 2021 18:24:23 +0200 Subject: [PATCH] Dont set the put_code if we didn't get it back. --- app/models/claim.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/models/claim.rb b/app/models/claim.rb index 24131750..628501b5 100644 --- a/app/models/claim.rb +++ b/app/models/claim.rb @@ -217,9 +217,16 @@ def process_data(options = {}) notify else if to_be_created? - update_columns(claimed_at: Time.zone.now, - put_code: result.body["put_code"], - error_messages: []) + to_update = { + :claimed_at => Time.zone.now, + :error_messages => [] + } + + if result.body["put_code"].present? + to_update[:put_code] = result.body["put_code"] + end + + update_columns(to_update) logger.info "[Done] #{uid} – #{doi} with Put Code #{result.body['put_code']}" elsif to_be_deleted?