diff --git a/apps/backend/hub_platform/identity/company_views.py b/apps/backend/hub_platform/identity/company_views.py index b5dbecf..bdc8d94 100644 --- a/apps/backend/hub_platform/identity/company_views.py +++ b/apps/backend/hub_platform/identity/company_views.py @@ -3,6 +3,7 @@ from rest_framework.request import Request from rest_framework.response import Response from rest_framework.views import APIView +from hub_platform.ai.models import AIAgent from hub_platform.identity.models import Department, EmployeeRole @@ -10,6 +11,9 @@ def _department_payload(department: Department) -> dict[str, object]: employees = list(department.employees.select_related("user").all()) operators = [employee for employee in employees if employee.role == EmployeeRole.OPERATOR] products = [link.product for link in department.product_links.select_related("product").order_by("product__name")] + # AI-агенты отдела: AIAgent живёт на канале обработки (ADR-HUB-0019), + # канал принадлежит отделу. Считаем активных агентов каналов этого отдела. + agent_count = AIAgent.objects.filter(channel__department=department).count() return { "id": department.id, "code": department.code, @@ -20,6 +24,7 @@ def _department_payload(department: Department) -> dict[str, object]: "activeOperatorCount": len( [employee for employee in operators if employee.user.is_active and not employee.is_blocked] ), + "agentCount": agent_count, "products": [{"code": product.code, "name": product.name} for product in products], } diff --git a/apps/internal-ui/src/features/departments/DepartmentsPage.tsx b/apps/internal-ui/src/features/departments/DepartmentsPage.tsx index 451090c..058ddb3 100644 --- a/apps/internal-ui/src/features/departments/DepartmentsPage.tsx +++ b/apps/internal-ui/src/features/departments/DepartmentsPage.tsx @@ -42,7 +42,7 @@ export function DepartmentsPage({ data, setRoute }: { data: AppData; setRoute: (