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:
@@ -48,6 +48,7 @@ def create_template(
|
||||
):
|
||||
"""Create a new campaign template."""
|
||||
template = campaign_service.create_template(db, data.model_dump())
|
||||
db.commit()
|
||||
return CampaignTemplateResponse.model_validate(template)
|
||||
|
||||
|
||||
@@ -60,6 +61,7 @@ def update_template(
|
||||
):
|
||||
"""Update a campaign template."""
|
||||
template = campaign_service.update_template(db, template_id, data.model_dump(exclude_none=True))
|
||||
db.commit()
|
||||
return CampaignTemplateResponse.model_validate(template)
|
||||
|
||||
|
||||
@@ -71,6 +73,7 @@ def delete_template(
|
||||
):
|
||||
"""Delete a campaign template."""
|
||||
campaign_service.delete_template(db, template_id)
|
||||
db.commit()
|
||||
return CampaignTemplateDeleteResponse(message="Template deleted")
|
||||
|
||||
|
||||
@@ -98,6 +101,7 @@ def send_campaign(
|
||||
prospect_ids=data.prospect_ids,
|
||||
sent_by_user_id=current_admin.user_id,
|
||||
)
|
||||
db.commit()
|
||||
return [CampaignSendResponse.model_validate(s) for s in sends]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user