refactor: move transaction management from services to API endpoints

- Services now use db.flush() instead of db.commit() for database operations
- API endpoints handle transaction commit after service calls
- Remove db.rollback() from services (let exception handlers manage this)
- Ensures consistent transaction boundaries at API layer

This pattern gives API endpoints full control over when to commit,
allowing for better error handling and potential multi-operation transactions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-06 18:34:41 +01:00
parent 5d40551d98
commit 3520bcb069
33 changed files with 118 additions and 119 deletions

View File

@@ -113,6 +113,7 @@ def create_setting(
"value_type": setting_data.value_type,
},
)
db.commit()
return result
@@ -140,6 +141,7 @@ def update_setting(
target_id=key,
details={"old_value": str(old_value), "new_value": update_data.value},
)
db.commit()
return result
@@ -168,6 +170,7 @@ def upsert_setting(
target_id=setting_data.key,
details={"category": setting_data.category},
)
db.commit()
return result
@@ -204,5 +207,6 @@ def delete_setting(
target_id=key,
details={},
)
db.commit()
return {"message": message}