add restore

This commit is contained in:
2025-12-19 18:42:27 -03:00
parent 01c7de34fa
commit 13f8126269
10 changed files with 175 additions and 23 deletions

View File

@@ -28,7 +28,7 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
subscription = enrollment_layer.collection.get_items(
TransactKey(enrollment_id)
+ SortKey('METADATA#SUBSCRIPTION_COVERED')
+ SortKey('CANCELED', path_spec='canceled_by', rename_key='canceled_by')
+ SortKey('CANCELED', rename_key='canceled_by')
)
created_at: datetime = fromisoformat(new_image['created_at']) # type: ignore
@@ -66,9 +66,17 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
}
| pick(('user', 'course', 'enrolled_at'), old_enrollment)
# Add `created_by` if present
| ({'author': canceled_by} if canceled_by else {}),
# Post-migration: uncomment the following line
# | ({'created_by': canceled_by} if canceled_by else {}),
| (
{
# Post-migration: rename `author` to `canceled_by`
'author': {
'id': canceled_by['user_id'],
'name': canceled_by['name'],
},
}
if canceled_by
else {}
),
cond_expr='attribute_not_exists(sk)',
)
except Exception as exc: