fix author

This commit is contained in:
2025-07-31 15:01:53 -03:00
parent 4b7783964f
commit f5bd1e80d6
2 changed files with 22 additions and 14 deletions

View File

@@ -96,7 +96,7 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
pass
try:
author = data['author']
author = data.get('author')
course_id = data['course']['id']
course = course_layer.collection.get_items(
KeyPair(
@@ -118,15 +118,21 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
'user': pick(('id', 'name'), data['user']),
'course': pick(('id', 'name'), data['course']),
'unit_price': course['unit_price'],
'author': {
'id': author['user_id'],
'name': author['name'],
},
# Post-migration: uncomment the following line
# 'enrolled_at': data['created_at'],
'enrolled_at': data['create_date'],
'created_at': now_,
},
}
| (
{
'author': {
'id': author['user_id'],
'name': author['name'],
}
}
if author
else {}
),
cond_expr='attribute_not_exists(sk)',
)
except Exception as exc: