From 390a5bc9aac45ea890022c617605cb0c0a935820 Mon Sep 17 00:00:00 2001 From: j Date: Sun, 8 Dec 2019 15:46:08 +0000 Subject: [PATCH 1/3] typo --- pandora/app/config.py | 2 +- pandora/document/views.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora/app/config.py b/pandora/app/config.py index bbe15994..b20686c3 100644 --- a/pandora/app/config.py +++ b/pandora/app/config.py @@ -96,7 +96,7 @@ def load_config(init=False): for key in config['documentKeys']: if key['id'] in default_filters and not key.get('filter'): key['filter'] = True - sys.stderr.write('enabled filter for documeny key "%s" since its used as default filter.\n' % (key['id'])) + sys.stderr.write('enabled filter for document key "%s" since its used as default filter.\n' % (key['id'])) config['keys'] = {} for key in config['itemKeys']: diff --git a/pandora/document/views.py b/pandora/document/views.py index 083090ee..2cc080e6 100644 --- a/pandora/document/views.py +++ b/pandora/document/views.py @@ -439,7 +439,7 @@ def upload(request): def autocompleteDocuments(request, data): ''' - Returns autocomplete strings for a given documeny key and search string + Returns autocomplete strings for a given document key and search string takes { key: string, // document key value: string, // search string From 234a5b67b979bd65fe00f34dcd8622941fb0de8f Mon Sep 17 00:00:00 2001 From: j Date: Sun, 8 Dec 2019 16:00:15 +0000 Subject: [PATCH 2/3] 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() From 2093922208d06e90c4bd9af89b93834fd245d917 Mon Sep 17 00:00:00 2001 From: j Date: Sun, 8 Dec 2019 21:19:23 +0000 Subject: [PATCH 3/3] year might be none or int --- pandora/item/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandora/item/models.py b/pandora/item/models.py index 695558c3..b9dd78ee 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -1049,7 +1049,9 @@ class Item(models.Model): value = len(value) set_value(s, name, value) elif sort_type == 'year': - value = self.get(source)[:4] + value = self.get(source) + if isinstance(value, str): + value = value[:4] set_value(s, name, value) elif sort_type == 'date': value = value_ = self.get(source)