add events

This commit is contained in:
2025-08-21 22:18:37 -03:00
parent c70a74b94a
commit 3ab20c485b
19 changed files with 315 additions and 164 deletions

View File

@@ -29,8 +29,8 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
TransactKey(enrollment_id)
+ SortKey('METADATA#SUBSCRIPTION_COVERED')
# Post-migration: uncomment the following line
# + SortKey('CANCELED', path_spec='author', rename_key='author')
+ SortKey('canceled', path_spec='author', rename_key='author')
# + SortKey('CANCELED', path_spec='canceled_by', rename_key='canceled_by')
+ SortKey('canceled', path_spec='author', rename_key='canceled_by')
)
created_at: datetime = fromisoformat(new_image['create_date']) # type: ignore
@@ -49,7 +49,7 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
return False
try:
author = subscription.get('author')
canceled_by = subscription.get('canceled_by')
# Retrieve canceled enrollment data
old_enrollment = order_layer.collection.get_item(
KeyPair(
@@ -68,7 +68,9 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
}
| pick(('user', 'course', 'enrolled_at'), old_enrollment)
# Add author if present
| ({'author': author} if author else {}),
| ({'author': canceled_by} if canceled_by else {}),
# Post-migration: uncomment the following line
# | ({'created_by': canceled_by} if canceled_by else {}),
cond_expr='attribute_not_exists(sk)',
)
except Exception as exc: