@@ -52,10 +52,10 @@ def handler(event, context):
5252 logger .info (f"Processing changes for document: { object_key } " )
5353 logger .info (f"Modified sections: { json .dumps (modified_sections )} " )
5454
55- # Use Document service to get the document
55+ # Use DynamoDB service to get the document (only service that supports get_document)
5656 try :
57- doc_service = create_document_service ()
58- document = doc_service .get_document (object_key ) # Returns Document object directly
57+ dynamodb_service = create_document_service (mode = 'dynamodb' )
58+ document = dynamodb_service .get_document (object_key ) # Returns Document object directly
5959
6060 if not document :
6161 raise ValueError (f"Document { object_key } not found" )
@@ -195,6 +195,16 @@ def handler(event, context):
195195 logger .warning ("QUEUE_URL not configured, skipping SQS message" )
196196 processing_job_id = None
197197
198+ # Use AppSync service for immediate UI status update
199+ try :
200+ appsync_service = create_document_service (mode = 'appsync' )
201+ document .status = Status .QUEUED # Ensure status is QUEUED for UI
202+ updated_document = appsync_service .update_document (document )
203+ logger .info (f"Updated document status to QUEUED in AppSync for immediate UI feedback" )
204+ except Exception as e :
205+ logger .warning (f"Failed to update document status in AppSync: { str (e )} " )
206+ # Don't fail the entire operation if AppSync update fails
207+
198208 # Log successful completion
199209 logger .info (f"Successfully processed changes for { len (modified_sections )} sections" )
200210
0 commit comments