refactor: remove db.commit() from audit_service.log_action, all callers use UoW
This commit is contained in:
@@ -68,14 +68,16 @@ def create_snapshot_endpoint(
|
||||
"""Create a manual coverage snapshot with an optional name."""
|
||||
snapshot = create_snapshot(db, name=payload.name, user_id=current_user.id)
|
||||
|
||||
log_action(
|
||||
db,
|
||||
user_id=current_user.id,
|
||||
action="create_snapshot",
|
||||
entity_type="snapshot",
|
||||
entity_id=snapshot.id,
|
||||
details={"name": snapshot.name, "score": snapshot.organization_score},
|
||||
)
|
||||
with UnitOfWork(db) as uow:
|
||||
log_action(
|
||||
db,
|
||||
user_id=current_user.id,
|
||||
action="create_snapshot",
|
||||
entity_type="snapshot",
|
||||
entity_id=snapshot.id,
|
||||
details={"name": snapshot.name, "score": snapshot.organization_score},
|
||||
)
|
||||
uow.commit()
|
||||
|
||||
return serialize_snapshot_summary(snapshot)
|
||||
|
||||
@@ -128,16 +130,15 @@ def delete_snapshot_endpoint(
|
||||
"""Delete a snapshot (admin only)."""
|
||||
snapshot = get_snapshot_or_raise(db, snapshot_id)
|
||||
|
||||
log_action(
|
||||
db,
|
||||
user_id=current_user.id,
|
||||
action="delete_snapshot",
|
||||
entity_type="snapshot",
|
||||
entity_id=snapshot.id,
|
||||
details={"name": snapshot.name},
|
||||
)
|
||||
|
||||
with UnitOfWork(db) as uow:
|
||||
log_action(
|
||||
db,
|
||||
user_id=current_user.id,
|
||||
action="delete_snapshot",
|
||||
entity_type="snapshot",
|
||||
entity_id=snapshot.id,
|
||||
details={"name": snapshot.name},
|
||||
)
|
||||
delete_snapshot(db, snapshot_id)
|
||||
uow.commit()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user