From d095a5bdfec4b079c59d3681e988d67bd95acbea Mon Sep 17 00:00:00 2001 From: Lova Andriarimalala <43842786+Xpirix@users.noreply.github.com> Date: Mon, 15 Jul 2024 10:49:34 +0300 Subject: [PATCH] Some improvements (#441) * Improve the rebuild search index task * Include dbbackups in make web command --- dockerize/Makefile | 9 +-------- qgis-app/plugins/tasks/rebuild_search_index.py | 10 ++++++---- qgis-app/settings_docker.py | 4 ++-- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/dockerize/Makefile b/dockerize/Makefile index 745c12ce..1522cfbc 100644 --- a/dockerize/Makefile +++ b/dockerize/Makefile @@ -35,14 +35,7 @@ web: db @echo "------------------------------------------------------------------" @echo "Running in production mode" @echo "------------------------------------------------------------------" - @docker compose -p $(PROJECT_ID) up -d --scale uwsgi=2 web worker beat - -dbbackups: db - @echo - @echo "------------------------------------------------------------------" - @echo "Running dbbackups in production mode" - @echo "------------------------------------------------------------------" - @docker compose -p $(PROJECT_ID) up -d dbbackups + @docker compose -p $(PROJECT_ID) up -d --scale uwsgi=2 web worker beat dbbackups certbot: web @echo diff --git a/qgis-app/plugins/tasks/rebuild_search_index.py b/qgis-app/plugins/tasks/rebuild_search_index.py index 198596d2..50c76d4d 100644 --- a/qgis-app/plugins/tasks/rebuild_search_index.py +++ b/qgis-app/plugins/tasks/rebuild_search_index.py @@ -1,10 +1,12 @@ from celery import shared_task +from haystack.management.commands import update_index from celery.utils.log import get_task_logger logger = get_task_logger(__name__) - @shared_task -def rebuild_index(): - import subprocess - subprocess.call(['python', 'manage.py', 'rebuild_index']) \ No newline at end of file +def rebuild_search_index(): + """ + Celery task to rebuild the search index. + """ + update_index.Command().handle() \ No newline at end of file diff --git a/qgis-app/settings_docker.py b/qgis-app/settings_docker.py index f3c6d085..5dd7c061 100644 --- a/qgis-app/settings_docker.py +++ b/qgis-app/settings_docker.py @@ -160,8 +160,8 @@ # Index synchronization sometimes fails when deleting # a plugin and None is listed in the search list. So I think # it would be better if we rebuild the index frequently - 'rebuild_index': { - 'task': 'plugins.tasks.rebuild_index.rebuild_index', + 'rebuild_search_index': { + 'task': 'plugins.tasks.rebuild_search_index.rebuild_search_index', 'schedule': crontab(minute=0, hour=3), # Execute every day at 3 AM. } }