update create_date field

This commit is contained in:
2025-08-27 11:53:39 -03:00
parent f055e144fb
commit b3a4b48fe5
2 changed files with 44 additions and 36 deletions

View File

@@ -23,7 +23,7 @@ dyn = DynamoDBPersistenceLayer(ENROLLMENT_TABLE, dynamodb_client)
@app.post('/') @app.post('/')
@tracer.capture_method @tracer.capture_method
def update_enrollment(): def postback():
json_body = app.current_event.json_body json_body = app.current_event.json_body
status = json_body['status'] status = json_body['status']

View File

@@ -65,6 +65,7 @@ def update_progress(
':progress': progress, ':progress': progress,
':updated_at': now_, ':updated_at': now_,
}, },
exc_cls=EnrollmentConflictError,
) )
# Record the start date if it does not already exist # Record the start date if it does not already exist
transact.put( transact.put(
@@ -140,7 +141,9 @@ def set_score(
user_id=user_id, user_id=user_id,
course_id=course_id, course_id=course_id,
cert_exp_interval=int( cert_exp_interval=int(
glom(enrollment, 'metadata__course.cert.exp_interval') glom(
enrollment, 'metadata__course.cert.exp_interval', default=0
)
), ),
dedup_window_offset_days=int( dedup_window_offset_days=int(
enrollment['dedup_window_offset_days'] enrollment['dedup_window_offset_days']
@@ -216,39 +219,42 @@ def _set_status_as_completed(
}, },
cond_expr='attribute_not_exists(sk)', cond_expr='attribute_not_exists(sk)',
) )
transact.put(
item={ if cert_exp_interval:
'id': id, transact.put(
'sk': 'SCHEDULE#REMINDER_CERT_EXPIRATION_BEFORE_30_DAYS', item={
'ttl': cert_expiration_reminder_ttl, 'id': id,
'created_at': now_, 'sk': 'SCHEDULE#REMINDER_CERT_EXPIRATION_BEFORE_30_DAYS',
} 'ttl': cert_expiration_reminder_ttl,
) 'created_at': now_,
transact.put( }
item={ )
'id': id, transact.put(
'sk': 'SCHEDULE#SET_AS_ARCHIVED', item={
'ttl': archive_ttl, 'id': id,
'created_at': now_, 'sk': 'SCHEDULE#SET_AS_ARCHIVED',
} 'ttl': archive_ttl,
) 'created_at': now_,
transact.put( }
item={ )
'id': id, transact.put(
'sk': 'LOCK', item={
'ttl': deduplication_lock_ttl, 'id': id,
'created_at': now_, 'sk': 'LOCK',
} 'ttl': deduplication_lock_ttl,
) 'created_at': now_,
transact.put( }
item={ )
'id': 'LOCK', transact.put(
'sk': lock_hash, item={
'enrollment_id': id, 'id': 'LOCK',
'ttl': deduplication_lock_ttl, 'sk': lock_hash,
'created_at': now_, 'enrollment_id': id,
} 'ttl': deduplication_lock_ttl,
) 'created_at': now_,
}
)
# Remove reminders and policies that no longer apply # Remove reminders and policies that no longer apply
transact.delete( transact.delete(
key=KeyPair( key=KeyPair(
@@ -420,4 +426,6 @@ class EnrollmentNotFoundError(NotFoundError):
super().__init__('Enrollment not found') super().__init__('Enrollment not found')
class EnrollmentConflictError(BadRequestError): ... class EnrollmentConflictError(BadRequestError):
def __init__(self, *_):
super().__init__('Enrollment conflict')