Spaces:
Paused
Paused
dushyantsingh0 commited on
Commit ·
37e1476
1
Parent(s): b002e3a
fix: resolve toFixed type crash on Nexus Control diagnostics
Browse files- api/v1/reports.py +22 -11
- api/v1/system.py +2 -2
api/v1/reports.py
CHANGED
|
@@ -168,20 +168,31 @@ async def get_ai_service_insights(
|
|
| 168 |
metrics = await get_sla_compliance(workspace_id, current_user, db)
|
| 169 |
|
| 170 |
# Strictly enforce current user's workspace, allowing override for Global Admin
|
|
|
|
|
|
|
|
|
|
| 171 |
target_ws = current_user.workspace_id
|
|
|
|
|
|
|
| 172 |
if workspace_id:
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
)
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
|
|
|
|
|
|
| 185 |
|
| 186 |
# 2. Get recent tickets for context (last 48 hours only for SPEED)
|
| 187 |
since_48h = datetime.utcnow() - timedelta(hours=48)
|
|
|
|
| 168 |
metrics = await get_sla_compliance(workspace_id, current_user, db)
|
| 169 |
|
| 170 |
# Strictly enforce current user's workspace, allowing override for Global Admin
|
| 171 |
+
from uuid import UUID
|
| 172 |
+
from models.user import UserRole
|
| 173 |
+
|
| 174 |
target_ws = current_user.workspace_id
|
| 175 |
+
role_str = str(current_user.role).lower()
|
| 176 |
+
|
| 177 |
if workspace_id:
|
| 178 |
+
try:
|
| 179 |
+
requested_ws = UUID(workspace_id) if isinstance(workspace_id, str) else workspace_id
|
| 180 |
+
|
| 181 |
+
if role_str == "3sc_admin" or role_str == "admin":
|
| 182 |
+
target_ws = requested_ws
|
| 183 |
+
else:
|
| 184 |
+
from models.user_workspace import UserWorkspace
|
| 185 |
+
ws_check = await db.execute(
|
| 186 |
+
select(UserWorkspace).where(
|
| 187 |
+
UserWorkspace.user_id == current_user.id,
|
| 188 |
+
UserWorkspace.workspace_id == requested_ws
|
| 189 |
+
)
|
| 190 |
)
|
| 191 |
+
if ws_check.scalar_one_or_none():
|
| 192 |
+
target_ws = requested_ws
|
| 193 |
+
except (ValueError, TypeError):
|
| 194 |
+
# Fallback to home workspace if invalid UUID passed
|
| 195 |
+
pass
|
| 196 |
|
| 197 |
# 2. Get recent tickets for context (last 48 hours only for SPEED)
|
| 198 |
since_48h = datetime.utcnow() - timedelta(hours=48)
|
api/v1/system.py
CHANGED
|
@@ -32,8 +32,8 @@ async def get_system_status(
|
|
| 32 |
infra_health = await check_infra_health(db, arq_pool)
|
| 33 |
|
| 34 |
results = {
|
| 35 |
-
"database": {"status": infra_health["database"], "latency_ms":
|
| 36 |
-
"redis": {"status": infra_health["redis"], "latency_ms":
|
| 37 |
"ollama": {"status": "DOWN", "latency_ms": 0},
|
| 38 |
"timestamp": datetime.utcnow()
|
| 39 |
}
|
|
|
|
| 32 |
infra_health = await check_infra_health(db, arq_pool)
|
| 33 |
|
| 34 |
results = {
|
| 35 |
+
"database": {"status": infra_health["database"], "latency_ms": 0},
|
| 36 |
+
"redis": {"status": infra_health["redis"], "latency_ms": 0, "pending_jobs": 0},
|
| 37 |
"ollama": {"status": "DOWN", "latency_ms": 0},
|
| 38 |
"timestamp": datetime.utcnow()
|
| 39 |
}
|