refactor: remove db.commit() from audit_service.log_action, all callers use UoW
This commit is contained in:
@@ -67,19 +67,18 @@ def update_data_source(
|
||||
**Requires** the ``admin`` role.
|
||||
"""
|
||||
update_data = body.model_dump(exclude_unset=True)
|
||||
update_source(db, source_id, **update_data)
|
||||
with UnitOfWork(db) as uow:
|
||||
update_source(db, source_id, **update_data)
|
||||
log_action(
|
||||
db,
|
||||
user_id=current_user.id,
|
||||
action="update_data_source",
|
||||
entity_type="data_source",
|
||||
entity_id=source_id,
|
||||
details={"updates": update_data},
|
||||
)
|
||||
uow.commit()
|
||||
|
||||
log_action(
|
||||
db,
|
||||
user_id=current_user.id,
|
||||
action="update_data_source",
|
||||
entity_type="data_source",
|
||||
entity_id=source_id,
|
||||
details={"updates": update_data},
|
||||
)
|
||||
|
||||
return {"message": "Data source updated", "id": source_id}
|
||||
|
||||
|
||||
@@ -107,14 +106,16 @@ def sync_all_data_sources(
|
||||
"""
|
||||
results = sync_all_sources(db)
|
||||
|
||||
log_action(
|
||||
db,
|
||||
user_id=current_user.id,
|
||||
action="sync_all_data_sources",
|
||||
entity_type="data_source",
|
||||
entity_id=None,
|
||||
details={"results": results},
|
||||
)
|
||||
with UnitOfWork(db) as uow:
|
||||
log_action(
|
||||
db,
|
||||
user_id=current_user.id,
|
||||
action="sync_all_data_sources",
|
||||
entity_type="data_source",
|
||||
entity_id=None,
|
||||
details={"results": results},
|
||||
)
|
||||
uow.commit()
|
||||
|
||||
return {"message": "Sync all complete", "results": results}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user