From 0ba5457e67e63c60f56c6ad050dcb4a72b1f9c3d Mon Sep 17 00:00:00 2001 From: Paul Schilling Date: Mon, 27 May 2024 15:49:27 +0200 Subject: [PATCH] [#2509] Create celery task to rebuild search index --- src/open_inwoner/search/tasks.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/open_inwoner/search/tasks.py diff --git a/src/open_inwoner/search/tasks.py b/src/open_inwoner/search/tasks.py new file mode 100644 index 0000000000..175c07cd87 --- /dev/null +++ b/src/open_inwoner/search/tasks.py @@ -0,0 +1,17 @@ +import logging + +from django.core.management import call_command +from django.utils.translation import gettext as _ + +from open_inwoner.celery import app + +logger = logging.getLogger(__name__) + + +@app.task(name=_("Rebuild search index")) +def rebuild_search_index(): + logger.info("starting rebuild_search_index() task") + + call_command("search_index", "--rebuild", "-f") + + logger.info("finished rebuild_search_index() task")