fix: unit_name в DTO операций (сигнатура _operation_dto с units_by_id)
This commit is contained in:
@@ -94,14 +94,17 @@ def list_operations(
|
||||
return {'items': [_operation_dto(o, users_by_id, units_by_id) for o in ops], 'total': len(ops)}
|
||||
|
||||
|
||||
def _operation_dto(op: SearchOperation, users_by_id: dict | None = None) -> dict[str, Any]:
|
||||
def _operation_dto(op: SearchOperation, users_by_id: dict | None = None,
|
||||
units_by_id: dict | None = None) -> dict[str, Any]:
|
||||
u = users_by_id or {}
|
||||
units = units_by_id or {}
|
||||
return {
|
||||
'id': str(op.id),
|
||||
'title': op.title,
|
||||
'case_id': str(op.case_id),
|
||||
'status': op.status,
|
||||
'unit_id': str(op.unit_id) if op.unit_id else None,
|
||||
'unit_name': units.get(str(op.unit_id)) if op.unit_id else None,
|
||||
'contour_operation_id': str(op.contour_operation_id) if op.contour_operation_id else None,
|
||||
'created_by_name': u.get(str(op.created_by)) if op.created_by else None,
|
||||
'created_at': op.created_at.isoformat() if op.created_at else None,
|
||||
|
||||
Reference in New Issue
Block a user