From 38379ab2b188aed7e2510d33f5b8ea2a89b570ff Mon Sep 17 00:00:00 2001 From: Herculino Trotta Date: Thu, 23 Jan 2025 21:12:13 -0300 Subject: [PATCH] feat(import): try to be more aggressive on cache invalidation --- app/apps/import_app/services/v1.py | 4 +--- app/apps/import_app/tasks.py | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/apps/import_app/services/v1.py b/app/apps/import_app/services/v1.py index a992630..b431f2b 100644 --- a/app/apps/import_app/services/v1.py +++ b/app/apps/import_app/services/v1.py @@ -542,6 +542,4 @@ class ImportService: self.import_run.finished_at = timezone.now() self.import_run.save(update_fields=["finished_at"]) - - if self.import_run.successful_rows >= 1: - cachalot.api.invalidate() + cachalot.api.invalidate() diff --git a/app/apps/import_app/tasks.py b/app/apps/import_app/tasks.py index cf6f3a7..44d63b4 100644 --- a/app/apps/import_app/tasks.py +++ b/app/apps/import_app/tasks.py @@ -1,5 +1,6 @@ import logging +import cachalot.api from procrastinate.contrib.django import app from apps.import_app.models import ImportRun @@ -14,5 +15,7 @@ def process_import(import_run_id: int, file_path: str): import_run = ImportRun.objects.get(id=import_run_id) import_service = ImportServiceV1(import_run) import_service.process_file(file_path) + cachalot.api.invalidate() except ImportRun.DoesNotExist: + cachalot.api.invalidate() raise ValueError(f"ImportRun with id {import_run_id} not found")