mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-07-15 09:12:39 +02:00
feat(import): disable cache when running
This commit is contained in:
@@ -7,8 +7,9 @@ from datetime import datetime
|
||||
from decimal import Decimal
|
||||
from typing import Dict, Any, Literal, Union
|
||||
|
||||
import cachalot.api
|
||||
import yaml
|
||||
from django.db import transaction
|
||||
from cachalot.api import cachalot_disabled
|
||||
from django.utils import timezone
|
||||
|
||||
from apps.accounts.models import Account, AccountGroup
|
||||
@@ -277,7 +278,7 @@ class ImportService:
|
||||
def _check_duplicate_transaction(self, transaction_data: Dict[str, Any]) -> bool:
|
||||
for rule in self.deduplication:
|
||||
if rule.type == "compare":
|
||||
query = Transaction.objects.all().values("id")
|
||||
query = Transaction.all_objects.all().values("id")
|
||||
|
||||
# Build query conditions for each field in the rule
|
||||
for field, header in rule.fields.items():
|
||||
@@ -484,7 +485,6 @@ class ImportService:
|
||||
|
||||
self._log("info", f"Starting import with {self.import_run.total_rows} rows")
|
||||
|
||||
with transaction.atomic():
|
||||
for row_number, row in enumerate(reader, start=1):
|
||||
self._process_row(row, row_number)
|
||||
self._increment_totals("processed", value=1)
|
||||
@@ -500,6 +500,7 @@ class ImportService:
|
||||
return abs_path
|
||||
|
||||
def process_file(self, file_path: str):
|
||||
with cachalot_disabled():
|
||||
# Validate and get absolute path
|
||||
file_path = self._validate_file_path(file_path)
|
||||
|
||||
@@ -539,3 +540,6 @@ 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()
|
||||
|
||||
Reference in New Issue
Block a user