refactor(prospecting): migrate SVC-006 transaction control to endpoint level
Some checks failed
Some checks failed
Move db.commit() from services to API endpoints and Celery tasks. Services now use db.flush() only; endpoints own the transaction. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -82,6 +82,7 @@ def create_prospect(
|
||||
data.model_dump(exclude_none=True),
|
||||
captured_by_user_id=current_admin.user_id,
|
||||
)
|
||||
db.commit()
|
||||
return _to_response(prospect)
|
||||
|
||||
|
||||
@@ -94,6 +95,7 @@ def update_prospect(
|
||||
):
|
||||
"""Update a prospect."""
|
||||
prospect = prospect_service.update(db, prospect_id, data.model_dump(exclude_none=True))
|
||||
db.commit()
|
||||
return _to_response(prospect)
|
||||
|
||||
|
||||
@@ -105,6 +107,7 @@ def delete_prospect(
|
||||
):
|
||||
"""Delete a prospect."""
|
||||
prospect_service.delete(db, prospect_id)
|
||||
db.commit()
|
||||
return ProspectDeleteResponse(message="Prospect deleted")
|
||||
|
||||
|
||||
@@ -125,6 +128,7 @@ async def import_domains(
|
||||
domains.append(domain)
|
||||
|
||||
created, skipped = prospect_service.create_bulk(db, domains, source="csv_import")
|
||||
db.commit()
|
||||
return ProspectImportResponse(created=created, skipped=skipped, total=len(domains))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user