diff --git a/annotations/tasks.py b/annotations/tasks.py index 05c5cc19..fdb76421 100644 --- a/annotations/tasks.py +++ b/annotations/tasks.py @@ -9,6 +9,8 @@ from django.contrib.contenttypes.models import ContentType import requests, uuid, re +from datetime import datetime, timedelta +from django.utils import timezone from itertools import groupby, chain from collections import defaultdict @@ -235,16 +237,17 @@ def accession_ready_relationsets(): relationsets = defaultdict(lambda: defaultdict(list)) for relationset in qs: - relationsets[relationset.occursIn.id][relationset.createdBy.id].append(relationset) - for text_id, text_rsets in relationsets.iteritems(): - for user_id, user_rsets in text_rsets.iteritems(): - - # Update state. - def _state(obj): - obj.pending = True - obj.save() - map(_state, user_rsets) - submit_relationsets_to_quadriga.delay(map(lambda o: o.id, user_rsets), text_id, user_id, **kwargs) + timeCreated = relationset.created + if timeCreated + timedelta(days=settings.SUBMIT_WAIT_TIME['days'], hours=settings.SUBMIT_WAIT_TIME['hours'], minutes=settings.SUBMIT_WAIT_TIME['minutes']) < datetime.now(timezone.utc): + relationsets[relationset.occursIn.id][relationset.createdBy.id].append(relationset) + for text_id, text_rsets in relationsets.iteritems(): + for user_id, user_rsets in text_rsets.iteritems(): + # Update state. + def _state(obj): + obj.pending = True + obj.save() + map(_state, user_rsets) + submit_relationsets_to_quadriga.delay(map(lambda o: o.id, user_rsets), text_id, user_id, **kwargs) # TODO: this should be retired. diff --git a/celerybeat-schedule.db b/celerybeat-schedule.db index 07ca4798..980ea9b3 100644 Binary files a/celerybeat-schedule.db and b/celerybeat-schedule.db differ diff --git a/requirements.txt b/requirements.txt index f3cd6e7d..a2659932 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,10 @@ anyjson==0.3.3 black-goat-client==0.2.6 bleach==1.4.2 celery==3.1.25 +certifi==2018.1.18 +chardet==3.0.4 conceptpower-api==1.9 +dicttoxml==1.6.6 dj-database-url==0.3.0 dj-static==0.0.6 Django==1.10.6 @@ -34,10 +37,8 @@ pytz==2016.10 redis==2.10.3 requests==2.13.0 requests-oauthlib==0.5.0 -restable>=0.1.3 +restable==0.1.3 +six==1.10.0 Unidecode==0.4.20 urllib3==1.19.1 xmltodict==0.10.2 -dicttoxml==1.6.6 -six==1.10.0 - diff --git a/vogon/settings.py b/vogon/settings.py index b2f00be7..6c633484 100644 --- a/vogon/settings.py +++ b/vogon/settings.py @@ -215,7 +215,7 @@ CELERYBEAT_SCHEDULE = { 'accession_ready_relationsets': { 'task': 'annotations.tasks.accession_ready_relationsets', - 'schedule': timedelta(seconds=600), + 'schedule': timedelta(minutes=10,seconds=0), }, } @@ -257,3 +257,9 @@ 'viaf:corporate': CORPORATE_CONCEPT_TYPE, # E40 Legal Body 'viaf:geographic': GEOGRAPHIC_CONCEPT_TYPE, # E53 Place } + +SUBMIT_WAIT_TIME = { + 'days': 3, + 'hours': 0, + 'minutes': 0 + } \ No newline at end of file