From 234a5b67b979bd65fe00f34dcd8622941fb0de8f Mon Sep 17 00:00:00 2001 From: j Date: Sun, 8 Dec 2019 16:00:15 +0000 Subject: [PATCH] extract fulltext in encoding queue --- pandora/document/models.py | 3 ++- pandora/document/tasks.py | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 pandora/document/tasks.py diff --git a/pandora/document/models.py b/pandora/document/models.py index 6f6466f0..4d85f785 100644 --- a/pandora/document/models.py +++ b/pandora/document/models.py @@ -30,6 +30,7 @@ from user.models import Group from . import managers from . import utils +from . import tasks from .fulltext import FulltextMixin User = get_user_model() @@ -507,7 +508,7 @@ class Document(models.Model, FulltextMixin): self.oshash = ox.oshash(self.file.path) self.save() self.delete_cache() - self.update_fulltext() + tasks.extract_fulltext.delay(self.id) return True, self.file.size return save_chunk(self, self.file, chunk, offset, name, done_cb) diff --git a/pandora/document/tasks.py b/pandora/document/tasks.py new file mode 100644 index 00000000..f08983bb --- /dev/null +++ b/pandora/document/tasks.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +from celery.task import task + +@task(queue="encoding") +def extract_fulltext(id): + from . import models + d = models.Document.objects.get(id=id) + d.update_fulltext()