add events
This commit is contained in:
@@ -44,6 +44,8 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
org_id = new_image['org_id']
|
||||
enrollment = enrollment_layer.collection.get_items(
|
||||
TransactKey(new_image['id']) + SortKey('0') + SortKey('author')
|
||||
# Post-migration: uncomment the following line
|
||||
# + SortKey('CREATED_BY')
|
||||
)
|
||||
|
||||
if not enrollment:
|
||||
@@ -97,7 +99,7 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
|
||||
# Add enrollment entry to billing
|
||||
try:
|
||||
author = enrollment.get('author')
|
||||
canceled_by = enrollment.get('author')
|
||||
course_id = enrollment['course']['id']
|
||||
course = course_layer.collection.get_items(
|
||||
KeyPair(
|
||||
@@ -129,11 +131,11 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
| (
|
||||
{
|
||||
'author': {
|
||||
'id': author['user_id'],
|
||||
'name': author['name'],
|
||||
'id': canceled_by['user_id'],
|
||||
'name': canceled_by['name'],
|
||||
}
|
||||
}
|
||||
if author
|
||||
if canceled_by
|
||||
else {}
|
||||
),
|
||||
cond_expr='attribute_not_exists(sk)',
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user