split tasks

This commit is contained in:
j 2019-04-12 10:01:49 +02:00
parent 776c4ff5b3
commit a311235cf6

View file

@ -8,9 +8,16 @@ from celery.task import periodic_task
def subtitles_user(**kwargs): def subtitles_user(**kwargs):
import annotation.models import annotation.models
from user.models import User from user.models import User
try:
u = User.objects.get(username='subtitles') u = User.objects.get(username='subtitles')
except User.DoesNotExist:
print('subtitles user does not exist, unable to move subtitles')
return
annotation.models.Annotation.objects.filter(layer='subtitles').exclude(user=u).update(user=u) annotation.models.Annotation.objects.filter(layer='subtitles').exclude(user=u).update(user=u)
@periodic_task(run_every=timedelta(hours=1), queue='encoding')
def update_ontology(**kwargs):
import annotation.models
t = datetime.now() - annotation.models.Annotation.objects.all().order_by('-created')[0].created t = datetime.now() - annotation.models.Annotation.objects.all().order_by('-created')[0].created
if t < timedelta(hours=1): if t < timedelta(hours=1):
try: try: