diff --git a/.secrets.baseline b/.secrets.baseline index 316ee80..9dafacc 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -133,9 +133,9 @@ "filename": "Makefile", "hashed_secret": "afc848c316af1a89d49826c5ae9d00ed769415f3", "is_verified": false, - "line_number": 102 + "line_number": 65 } ] }, - "generated_at": "2024-09-09T12:08:54Z" + "generated_at": "2024-12-10T03:50:08Z" } diff --git a/Makefile b/Makefile index 98db6ba..fe56b1b 100644 --- a/Makefile +++ b/Makefile @@ -62,6 +62,7 @@ first-use: # Initialise for local execution @echo "$(COLOUR_GREEN)Destroy containers with 'make down'$(COLOUR_NONE)" up: # Build, (re)create and start containers + export DATABASE_URL=postgres://postgres:postgres@localhost:5432/fbr docker compose up -d @echo "$(COLOUR_GREEN)Services are up - use 'make logs' to view service logs$(COLOUR_NONE)" @@ -107,10 +108,12 @@ django-shell-local: # Run a Django shell (local django instance) poetry run python manage.py shell migrate: # Run Django migrate - docker compose run --rm web poetry run python manage.py migrate --noinput + export DATABASE_URL=postgres://postgres:postgres@localhost:5432/fbr && \ + python manage.py migrate migrations: # Run Django makemigrations - docker compose run --rm web poetry run python manage.py makemigrations --noinput + export DATABASE_URL=postgres://postgres:postgres@localhost:5432/fbr && \ + python manage.py makemigrations lint: # Run all linting make black @@ -136,6 +139,7 @@ setup_local: # Set up the local environment @echo "$(COLOUR_GREEN)Running initial setup for local environment...$(COLOUR_NONE)" $(MAKE) first-use $(MAKE) start - #$(MAKE) migrate + #$(MAKE) migrations + $(MAKE) migrate #$(MAKE) rebuild_cache @echo "$(COLOUR_GREEN)Local setup complete.$(COLOUR_NONE)" diff --git a/celery_worker/tasks.py b/celery_worker/tasks.py index ecaf9d0..28d22c9 100644 --- a/celery_worker/tasks.py +++ b/celery_worker/tasks.py @@ -8,8 +8,8 @@ from app.search.utils.documents import clear_all_documents -@shared_task(bind=True) -def rebuild_cache() -> None: +@shared_task(name="celery_worker.tasks.rebuild_cache") +def rebuild_cache(): """ Rebuilds the cache for search documents across various components by clearing all existing documents. The process is timed, and the diff --git a/docker-compose.yml b/docker-compose.yml index 58b908b..4ab610b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -72,6 +72,7 @@ services: DEBUG: true DJANGO_SETTINGS_MODULE: fbr.settings RDS_POSTGRES_CREDENTIALS: '{"password":"postgres","dbname":"fbr","engine":"postgres","port":5432,"dbInstanceIdentifier":"xxx","host":"db","username":"postgres"}' + DATABASE_URL: postgres://postgres:postgres@host.docker.internal:5432/fbr # pragma: allowlist secret celery-beats: build: diff --git a/fbr/celery_app.py b/fbr/celery_app.py index 6e33420..e7e4fad 100644 --- a/fbr/celery_app.py +++ b/fbr/celery_app.py @@ -19,6 +19,6 @@ celery_app.conf.beat_schedule = { "schedule-fbr-cache-task": { "task": "celery_worker.tasks.rebuild_cache", - "schedule": crontab(hour="1", minute="0"), # Runs daily at 1:00 AM + "schedule": crontab(hour="3", minute="46"), # Runs daily at 1:00 AM }, } diff --git a/fbr/settings.py b/fbr/settings.py index 0c6db18..9a82355 100644 --- a/fbr/settings.py +++ b/fbr/settings.py @@ -60,6 +60,7 @@ "app", "app.core", "app.search", + "celery_worker", ] THIRD_PARTY_APPS: list = [ @@ -120,7 +121,7 @@ DATABASES = { "default": { "ENGINE": "django.db.backends.sqlite3", - "NAME": SITE_ROOT / "db.sqlite3", + "NAME": BASE_DIR / "db.sqlite3", } }