Skip to content

Commit 9c5fb13

Browse files
Merge pull request #5 from agile-learning-institute/auto-processing-improvements
Auto processing improvements
2 parents 222ba61 + 4fc38f2 commit 9c5fb13

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

stage0_mongodb_api/managers/config_manager.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,16 @@ def process_all_collections(self) -> Dict[str, List[Dict]]:
170170
Dict[str, List[Dict]]: Dictionary mapping collection names to their operation results
171171
"""
172172
results = {}
173+
any_collection_failed = False
173174

174175
for collection_name in self.collection_configs.keys():
175176
try:
176177
results[collection_name] = self.process_collection_versions(collection_name)
178+
179+
# Check if this collection had any errors
180+
if any(isinstance(op, dict) and op.get("status") == "error" for op in results[collection_name]):
181+
any_collection_failed = True
182+
177183
except Exception as e:
178184
logger.error(f"Error processing collection {collection_name}: {str(e)}")
179185
results[collection_name] = [{
@@ -182,6 +188,23 @@ def process_all_collections(self) -> Dict[str, List[Dict]]:
182188
"error": str(e),
183189
"status": "error"
184190
}]
191+
any_collection_failed = True
192+
193+
# Add final overall status operation
194+
overall_status = "error" if any_collection_failed else "success"
195+
overall_message = "Some collections failed to process" if any_collection_failed else "All collections processed successfully"
196+
197+
# Add the overall status to each collection's results
198+
for collection_name in results.keys():
199+
results[collection_name].append({
200+
"operation": "overall_status",
201+
"status": overall_status,
202+
"message": overall_message,
203+
"collections_processed": len(self.collection_configs),
204+
"collections_failed": sum(1 for result in results.values()
205+
if any(isinstance(op, dict) and op.get("status") == "error"
206+
for op in result))
207+
})
185208

186209
return results
187210

stage0_mongodb_api/server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import sys
23
import signal
34
from flask import Flask
@@ -47,7 +48,7 @@ def handle_exit(signum, frame):
4748

4849
# Process all collections
4950
processing_output = config_manager.process_all_collections()
50-
logger.info(f"Processing Output: {processing_output}")
51+
logger.info(f"Processing Output: {json.dumps(processing_output, indent=4)}")
5152
logger.info(f"============= Auto Processing is Completed ===============")
5253

5354
if config.EXIT_AFTER_PROCESSING:

0 commit comments

Comments
 (0)