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('/')
@tracer.capture_method
def update_enrollment():
def postback():
json_body = app.current_event.json_body
status = json_body['status']

View File

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