Skip to content

Commit

Permalink
save only at the end or on error
Browse files Browse the repository at this point in the history
kjgarza committed Oct 14, 2019

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent 4f29915 commit 00445af
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/models/claim.rb
Original file line number Diff line number Diff line change
@@ -185,13 +185,13 @@ def to_param # overridden, use uuid instead of id
def process_data(options={})
logger = Logger.new(STDOUT)

self.start!
self.start

### depdency Injection for testing
result = options[:collect_data] || collect_data

if result.body["skip"]
claimed_at.present? ? self.finish! : self.skip!
claimed_at.present? ? self.finish : self.skip

logger.warn "[Skipped] #{self.uid}#{self.doi}] #{result.body["reason"]}"
elsif result.body["errors"]
@@ -209,7 +209,7 @@ def process_data(options={})

logger.warn "[Notification] #{self.uid}#{self.doi}] with Put Code #{result.body["put_code"]}"

self.notify!
self.notify
else
if to_be_created?
write_attribute(:claimed_at, Time.zone.now)

0 comments on commit 00445af

Please sign in to comment.