From f7b8524f2deb603fcf88c4949b02282822dc891f Mon Sep 17 00:00:00 2001 From: Mike Storey Date: Tue, 24 Jun 2025 19:39:40 -0400 Subject: [PATCH 1/2] json.dump processing output --- stage0_mongodb_api/server.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stage0_mongodb_api/server.py b/stage0_mongodb_api/server.py index 44b42aa..5ef6c41 100644 --- a/stage0_mongodb_api/server.py +++ b/stage0_mongodb_api/server.py @@ -1,3 +1,4 @@ +import json import sys import signal from flask import Flask @@ -47,7 +48,7 @@ def handle_exit(signum, frame): # Process all collections processing_output = config_manager.process_all_collections() - logger.info(f"Processing Output: {processing_output}") + logger.info(f"Processing Output: {json.dumps(processing_output, indent=4)}") logger.info(f"============= Auto Processing is Completed ===============") if config.EXIT_AFTER_PROCESSING: From 4fc38f29a6b14dff29481a7a8df8f33775c2a009 Mon Sep 17 00:00:00 2001 From: Mike Storey Date: Tue, 24 Jun 2025 19:48:15 -0400 Subject: [PATCH 2/2] Adding a final processing operation to summarize Collection success and failure --- stage0_mongodb_api/managers/config_manager.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/stage0_mongodb_api/managers/config_manager.py b/stage0_mongodb_api/managers/config_manager.py index b6189ff..51c3f48 100644 --- a/stage0_mongodb_api/managers/config_manager.py +++ b/stage0_mongodb_api/managers/config_manager.py @@ -170,10 +170,16 @@ def process_all_collections(self) -> Dict[str, List[Dict]]: Dict[str, List[Dict]]: Dictionary mapping collection names to their operation results """ results = {} + any_collection_failed = False for collection_name in self.collection_configs.keys(): try: results[collection_name] = self.process_collection_versions(collection_name) + + # Check if this collection had any errors + if any(isinstance(op, dict) and op.get("status") == "error" for op in results[collection_name]): + any_collection_failed = True + except Exception as e: logger.error(f"Error processing collection {collection_name}: {str(e)}") results[collection_name] = [{ @@ -182,6 +188,23 @@ def process_all_collections(self) -> Dict[str, List[Dict]]: "error": str(e), "status": "error" }] + any_collection_failed = True + + # Add final overall status operation + overall_status = "error" if any_collection_failed else "success" + overall_message = "Some collections failed to process" if any_collection_failed else "All collections processed successfully" + + # Add the overall status to each collection's results + for collection_name in results.keys(): + results[collection_name].append({ + "operation": "overall_status", + "status": overall_status, + "message": overall_message, + "collections_processed": len(self.collection_configs), + "collections_failed": sum(1 for result in results.values() + if any(isinstance(op, dict) and op.get("status") == "error" + for op in result)) + }) return results