Skip to content

Commit 8c00be7

Browse files
author
Bob Strahan
committed
Update process changes resolver to use DynamoDB for document retrieval and AppSync for UI updates
1 parent 9fc377b commit 8c00be7

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/lambda/process_changes_resolver/index.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

template.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6194,7 +6194,6 @@ Resources:
61946194
Variables:
61956195
LOG_LEVEL: !Ref LogLevel
61966196
TRACKING_TABLE: !Ref TrackingTable
6197-
DOCUMENT_TRACKING_MODE: 'dynamodb'
61986197
QUEUE_URL: !Ref DocumentQueue
61996198
DATA_RETENTION_IN_DAYS: !Ref DataRetentionInDays
62006199
WORKING_BUCKET: !Ref WorkingBucket

0 commit comments

Comments
 (0)