Spaces:
Running
Running
Handle invalid analytics in session results
Browse files
app.py
CHANGED
|
@@ -1035,7 +1035,16 @@ def results(session_id: UUID, request: Request):
|
|
| 1035 |
if report.get("error"):
|
| 1036 |
failed.append({"id": str(uuid5(session_id, str(index))), "label": label, "start": str(start), "end": str(end), "error": report["error"]})
|
| 1037 |
continue
|
| 1038 |
-
analytics = report.get("analytics")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1039 |
metrics = [{"name": key.replace("_", " ").title(), "value": value, "unit": ""} for key, value in analytics.items() if isinstance(value, (int, float, str, bool)) or value is None]
|
| 1040 |
full_interval = report.get("full_interval") or {}
|
| 1041 |
telemetry_names = {
|
|
|
|
| 1035 |
if report.get("error"):
|
| 1036 |
failed.append({"id": str(uuid5(session_id, str(index))), "label": label, "start": str(start), "end": str(end), "error": report["error"]})
|
| 1037 |
continue
|
| 1038 |
+
analytics = report.get("analytics")
|
| 1039 |
+
if isinstance(analytics, str):
|
| 1040 |
+
failed.append({"id": str(uuid5(session_id, str(index))), "label": label,
|
| 1041 |
+
"start": str(start), "end": str(end), "error": analytics})
|
| 1042 |
+
continue
|
| 1043 |
+
if not isinstance(analytics, dict):
|
| 1044 |
+
failed.append({"id": str(uuid5(session_id, str(index))), "label": label,
|
| 1045 |
+
"start": str(start), "end": str(end),
|
| 1046 |
+
"error": "Analysis data is incomplete; no valid analytics were saved for this action."})
|
| 1047 |
+
continue
|
| 1048 |
metrics = [{"name": key.replace("_", " ").title(), "value": value, "unit": ""} for key, value in analytics.items() if isinstance(value, (int, float, str, bool)) or value is None]
|
| 1049 |
full_interval = report.get("full_interval") or {}
|
| 1050 |
telemetry_names = {
|