Skip to content

Commit 196d438

Browse files
author
Shreyas-Microsoft
committed
fix batch summary
1 parent 137cdad commit 196d438

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

src/backend/common/services/batch_service.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ async def get_file_report(self, file_id: str) -> Optional[Dict]:
6161
storage = await BlobStorageFactory.get_storage()
6262
if file_record.translated_path not in ["", None]:
6363
translated_content = await storage.get_file(file_record.translated_path)
64+
else:
65+
# If translated_path is empty, try to get translated content from logs
66+
# Look for the final success log with the translated result
67+
if logs:
68+
for log in logs:
69+
if (log.get("log_type") == "success" and
70+
log.get("agent_type") == "agents" and
71+
log.get("last_candidate")):
72+
translated_content = log["last_candidate"]
73+
break
6474
except IOError as e:
6575
self.logger.error(f"Error downloading file content: {str(e)}")
6676

@@ -79,6 +89,16 @@ async def get_file_translated(self, file: dict):
7989
storage = await BlobStorageFactory.get_storage()
8090
if file["translated_path"] not in ["", None]:
8191
translated_content = await storage.get_file(file["translated_path"])
92+
else:
93+
# If translated_path is empty, try to get translated content from logs
94+
# Look for the final success log with the translated result
95+
if "logs" in file and file["logs"]:
96+
for log in file["logs"]:
97+
if (log.get("log_type") == "success" and
98+
log.get("agent_type") == "agents" and
99+
log.get("last_candidate")):
100+
translated_content = log["last_candidate"]
101+
break
82102
except IOError as e:
83103
self.logger.error(f"Error downloading file content: {str(e)}")
84104

@@ -126,7 +146,8 @@ async def get_batch_summary(self, batch_id: str, user_id: str) -> Optional[Dict]
126146
try:
127147
logs = await self.database.get_file_logs(file["file_id"])
128148
file["logs"] = logs
129-
if file["translated_path"]:
149+
# Try to get translated content for completed files
150+
if file.get("status") == "completed":
130151
try:
131152
translated_content = await self.get_file_translated(file)
132153
file["translated_content"] = translated_content

0 commit comments

Comments
 (0)