Skip to content

Commit

Permalink
refactor:task module and update redis dependency
Browse files Browse the repository at this point in the history
Renamed tasks module and updated Celery task name for consistency and clarity. Upgraded redis package from version 5.2.0 to 5.2.1 in poetry.lock and pyproject.toml to ensure compatibility and improvements. Added import statement in fbr/__init__.py for app initialization during Django startup.
  • Loading branch information
hareshkainthdbt committed Dec 7, 2024
1 parent 68937c0 commit 7e6868a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
7 changes: 7 additions & 0 deletions fbr/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from __future__ import absolute_import, unicode_literals

# This ensures the app is always imported when Django starts
# allowing shared_task to utilize this app.
from .config.celery import celery_app

__all__ = ("celery_app",)
6 changes: 5 additions & 1 deletion fbr/config/celery.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# isort:skip_file

from __future__ import absolute_import, unicode_literals

import os

from celery import Celery
Expand All @@ -24,7 +28,7 @@ def setup_periodic_tasks(sender, **kwargs):
def get_cache_beat_schedule():
return {
"schedule-fbr-cache-task": {
"task": "fbr.cache.tasks.rebuild_cache",
"task": "fbr.tasks.rebuild_cache",
"schedule": crontab(hour="1", minute="0"), # Runs daily at 1:00 AM
},
}
2 changes: 1 addition & 1 deletion fbr/cache/tasks.py → fbr/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from fbr.search.utils.documents import clear_all_documents


@celery_app.task(name="fbr.cache.tasks.rebuild_cache")
@celery_app.task(name="fbr.tasks.rebuild_cache")
def rebuild_cache() -> None:
"""
Rebuilds the cache for search documents across various components by
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ kombu = {extras = ["redis"], version = "^5.4.2"}
boto3 = "^1.35.71"
django-celery-beat = "^2.7.0"
django-environ = "^0.11.2"
redis = "^5.2.1"

[tool.poetry.group.dev.dependencies]
pre-commit = "^3.7.1"
Expand Down

0 comments on commit 7e6868a

Please sign in to comment.