Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ctrl/command/middle-mouse click #2170
- ⚡️(frontend) add jitter to WS reconnection #2162
- 🐛(frontend) fix tree pagination #2145
- 🐛(nginx) add page reconciliation on nginx #2154

- 🐛(backend) fix race condition in reconciliation requests CSV import #2153

## [v4.8.4] - 2026-03-25

Expand Down
7 changes: 6 additions & 1 deletion src/backend/core/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
"""Admin classes and registrations for core app."""

from functools import partial

from django.contrib import admin, messages
from django.contrib.auth import admin as auth_admin
from django.db import transaction
from django.shortcuts import redirect
from django.utils.translation import gettext_lazy as _

Expand Down Expand Up @@ -108,7 +111,9 @@ def save_model(self, request, obj, form, change):
super().save_model(request, obj, form, change)

if not change:
user_reconciliation_csv_import_job.delay(obj.pk)
transaction.on_commit(
Comment thread
lunika marked this conversation as resolved.
partial(user_reconciliation_csv_import_job.delay, obj.pk)
)
Comment thread
Ash-Crow marked this conversation as resolved.
messages.success(request, _("Import job created and queued."))
return redirect("..")

Expand Down
11 changes: 9 additions & 2 deletions src/backend/core/tasks/user_reconciliation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Processing tasks for user reconciliation CSV imports."""

import csv
import logging
import traceback
import uuid

Expand All @@ -14,6 +15,8 @@

from impress.celery_app import app

logger = logging.getLogger(__name__)


def _process_row(row, job, counters):
"""Process a single row from the CSV file."""
Expand Down Expand Up @@ -89,8 +92,12 @@ def user_reconciliation_csv_import_job(job_id):
Rows with errors are logged in the job logs and skipped, but do not cause
the entire job to fail or prevent the next rows from being processed.
"""
# Imports the CSV file, breaks it into UserReconciliation items
job = UserReconciliationCsvImport.objects.get(id=job_id)
try:
job = UserReconciliationCsvImport.objects.get(id=job_id)
except UserReconciliationCsvImport.DoesNotExist:
logger.warning("CSV import job %s no longer exists; skipping.", job_id)
return

job.status = "running"
job.save()

Expand Down
Loading