update events
This commit is contained in:
@@ -25,7 +25,8 @@ def update_progress(
|
||||
# Update progress only if the enrollment status is `IN_PROGRESS`
|
||||
transact.update(
|
||||
key=KeyPair(id, '0'),
|
||||
update_expr='SET progress = :progress, updated_at = :updated_at',
|
||||
update_expr='SET progress = :progress, \
|
||||
updated_at = :now',
|
||||
cond_expr='#status = :in_progress',
|
||||
expr_attr_names={
|
||||
'#status': 'status',
|
||||
@@ -33,7 +34,7 @@ def update_progress(
|
||||
expr_attr_values={
|
||||
':in_progress': 'IN_PROGRESS',
|
||||
':progress': progress,
|
||||
':updated_at': now_,
|
||||
':now': now_,
|
||||
},
|
||||
exc_cls=EnrollmentConflictError,
|
||||
)
|
||||
@@ -49,11 +50,12 @@ def update_progress(
|
||||
except EnrollmentConflictError:
|
||||
with dynamodb_persistence_layer.transact_writer() as transact:
|
||||
# If the enrollment status is `PENDING`, set it to `IN_PROGRESS`
|
||||
# and update progress and updated_at date
|
||||
# and update `progress` and `updated_at`
|
||||
transact.update(
|
||||
key=KeyPair(id, '0'),
|
||||
update_expr='SET progress = :progress, #status = :in_progress, \
|
||||
updated_at = :updated_at',
|
||||
update_expr='SET progress = :progress, \
|
||||
#status = :in_progress, \
|
||||
updated_at = :now',
|
||||
cond_expr='#status = :pending',
|
||||
expr_attr_names={
|
||||
'#status': 'status',
|
||||
@@ -62,7 +64,7 @@ def update_progress(
|
||||
':in_progress': 'IN_PROGRESS',
|
||||
':pending': 'PENDING',
|
||||
':progress': progress,
|
||||
':updated_at': now_,
|
||||
':now': now_,
|
||||
},
|
||||
exc_cls=EnrollmentConflictError,
|
||||
)
|
||||
@@ -189,15 +191,15 @@ def _set_status_as_completed(
|
||||
update_expr='SET #status = :completed, \
|
||||
progress = :progress, \
|
||||
score = :score, \
|
||||
updated_at = :updated_at',
|
||||
updated_at = :now',
|
||||
cond_expr='#status = :in_progress',
|
||||
expr_attr_names={'#status': 'status'},
|
||||
expr_attr_values={
|
||||
':completed': 'COMPLETED',
|
||||
':in_progress': 'IN_PROGRESS',
|
||||
':score': score,
|
||||
':updated_at': now_,
|
||||
':progress': progress,
|
||||
':now': now_,
|
||||
},
|
||||
exc_cls=EnrollmentConflictError,
|
||||
)
|
||||
@@ -214,7 +216,7 @@ def _set_status_as_completed(
|
||||
transact.put(
|
||||
item={
|
||||
'id': id,
|
||||
'sk': 'SCHEDULE#REMINDER_CERT_EXPIRATION_BEFORE_30_DAYS',
|
||||
'sk': 'SCHEDULE#SET_CERT_EXPIRED',
|
||||
'ttl': cert_exp_ttl,
|
||||
'created_at': now_,
|
||||
}
|
||||
@@ -222,7 +224,7 @@ def _set_status_as_completed(
|
||||
transact.put(
|
||||
item={
|
||||
'id': id,
|
||||
'sk': 'SCHEDULE#SET_CERT_EXPIRED',
|
||||
'sk': 'SCHEDULE#REMINDER_CERT_EXPIRATION_BEFORE_30_DAYS',
|
||||
'ttl': cert_exp_reminder_ttl,
|
||||
'created_at': now_,
|
||||
}
|
||||
@@ -288,8 +290,8 @@ def _set_status_as_failed(
|
||||
update_expr='SET #status = :failed, \
|
||||
progress = :progress, \
|
||||
score = :score, \
|
||||
access_expired = :access_expired, \
|
||||
updated_at = :updated_at',
|
||||
access_expired = :true, \
|
||||
updated_at = :now',
|
||||
cond_expr='#status = :in_progress',
|
||||
expr_attr_names={'#status': 'status'},
|
||||
expr_attr_values={
|
||||
@@ -297,8 +299,8 @@ def _set_status_as_failed(
|
||||
':in_progress': 'IN_PROGRESS',
|
||||
':score': score,
|
||||
':progress': progress,
|
||||
':access_expired': True,
|
||||
':updated_at': now_,
|
||||
':true': True,
|
||||
':now': now_,
|
||||
},
|
||||
exc_cls=EnrollmentConflictError,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user