Skip to content

Commit

Permalink
Account orphaned+duplicate requests (#183 & #177)
Browse files Browse the repository at this point in the history
  • Loading branch information
x0xMaximus committed Nov 16, 2016
1 parent 77fd56b commit 08c211d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mark2cure/document/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def run_pubtator(self):
pending_request = pubtator.pubtatorrequest_set.get(status=PubtatorRequest.UNFULLFILLED)
except PubtatorRequest.DoesNotExist:
pending_request = False
except PubtatorRequest.MultipleObjectsReturned:
# Why where there multiple open at once? Just delete them all and start fresh
pubtator.pubtatorrequest_set.filter(status=PubtatorRequest.UNFULLFILLED).all().delete()
pending_request = False

# If we successfully retrieved in the past, but it's old now
if last_request and (timezone.now() - last_request.updated).days >= 60 and not pending_request:
Expand All @@ -62,6 +66,10 @@ def run_pubtator(self):
pubtator.submit()
return

if not last_request and not pending_request:
pubtator.submit()
return

def update_padding(self):
from mark2cure.common.formatter import pad_split
changed = False
Expand Down

0 comments on commit 08c211d

Please sign in to comment.