Skip to content

Commit bbbb089

Browse files
author
Mike Storey
committed
Improve: only add overall_status to collections that actually failed
1 parent eb470b8 commit bbbb089

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

stage0_mongodb_api/managers/config_manager.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -213,21 +213,30 @@ def process_all_collections(self) -> Dict[str, List[Dict]]:
213213
overall_status = "error" if any_collection_failed else "success"
214214
overall_message = "Some collections failed to process" if any_collection_failed else "All collections processed successfully"
215215

216-
# Add the overall status to each collection's results
216+
# Add the overall status only to collections that actually failed
217217
for collection_name in results.keys():
218-
results[collection_name].append({
219-
"operation": "overall_status",
220-
"message": overall_message,
221-
"details_type": "overall",
222-
"details": {
223-
"collections_processed": len(self.collection_configs),
224-
"collections_failed": sum(1 for result in results.values()
225-
if any(isinstance(op, dict) and op.get("status") == "error"
226-
and op.get("operation") != "overall_status"
227-
for op in result))
228-
},
229-
"status": overall_status
230-
})
218+
# Check if this collection had any errors (excluding overall_status operations)
219+
collection_has_errors = any(
220+
isinstance(op, dict) and op.get("status") == "error"
221+
and op.get("operation") != "overall_status"
222+
for op in results[collection_name]
223+
)
224+
225+
# Only add overall_status to collections that failed
226+
if collection_has_errors:
227+
results[collection_name].append({
228+
"operation": "overall_status",
229+
"message": overall_message,
230+
"details_type": "overall",
231+
"details": {
232+
"collections_processed": len(self.collection_configs),
233+
"collections_failed": sum(1 for result in results.values()
234+
if any(isinstance(op, dict) and op.get("status") == "error"
235+
and op.get("operation") != "overall_status"
236+
for op in result))
237+
},
238+
"status": overall_status
239+
})
231240

232241
return results
233242

0 commit comments

Comments
 (0)