fix billing
This commit is contained in:
@@ -86,21 +86,27 @@ def update_progress(
|
||||
}
|
||||
)
|
||||
# Remove reminders and policies that no longer apply
|
||||
transact.delete(
|
||||
key=KeyPair(
|
||||
pk=id,
|
||||
sk='CANCEL_POLICY',
|
||||
),
|
||||
)
|
||||
transact.delete(
|
||||
key=KeyPair(
|
||||
pk=id,
|
||||
sk='SCHEDULE#REMINDER_NO_ACCESS_AFTER_3_DAYS',
|
||||
)
|
||||
)
|
||||
transact.delete(
|
||||
key=KeyPair(pk=id, sk='CANCEL_POLICY'),
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def set_score(
|
||||
id: str,
|
||||
/,
|
||||
score: Decimal,
|
||||
progress: Decimal,
|
||||
*,
|
||||
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
|
||||
):
|
||||
@@ -138,6 +144,7 @@ def set_score(
|
||||
return _set_status_as_completed(
|
||||
id,
|
||||
score,
|
||||
progress=progress,
|
||||
user_id=user_id,
|
||||
course_id=course_id,
|
||||
cert_exp_interval=int(
|
||||
@@ -161,6 +168,7 @@ def set_score(
|
||||
return _set_status_as_failed(
|
||||
id,
|
||||
score,
|
||||
progress=progress,
|
||||
user_id=user_id,
|
||||
course_id=course_id,
|
||||
dynamodb_persistence_layer=dynamodb_persistence_layer,
|
||||
@@ -174,6 +182,7 @@ def _set_status_as_completed(
|
||||
id: str,
|
||||
/,
|
||||
score: Decimal,
|
||||
progress: Decimal,
|
||||
*,
|
||||
user_id: str,
|
||||
course_id: str,
|
||||
@@ -199,8 +208,8 @@ def _set_status_as_completed(
|
||||
with dynamodb_persistence_layer.transact_writer() as transact:
|
||||
transact.update(
|
||||
key=KeyPair(pk=id, sk='0'),
|
||||
update_expr='SET #status = :completed, score = :score, \
|
||||
updated_at = :updated_at',
|
||||
update_expr='SET #status = :completed, progress = :progress, \
|
||||
score = :score, updated_at = :updated_at',
|
||||
cond_expr='#status = :in_progress',
|
||||
expr_attr_names={'#status': 'status'},
|
||||
expr_attr_values={
|
||||
@@ -208,6 +217,7 @@ def _set_status_as_completed(
|
||||
':in_progress': 'IN_PROGRESS',
|
||||
':score': score,
|
||||
':updated_at': now_,
|
||||
':progress': progress,
|
||||
},
|
||||
exc_cls=EnrollmentConflictError,
|
||||
)
|
||||
@@ -242,6 +252,7 @@ def _set_status_as_completed(
|
||||
'id': id,
|
||||
'sk': 'LOCK',
|
||||
'ttl': deduplication_lock_ttl,
|
||||
'hash': lock_hash,
|
||||
'created_at': now_,
|
||||
}
|
||||
)
|
||||
@@ -256,6 +267,12 @@ def _set_status_as_completed(
|
||||
)
|
||||
|
||||
# Remove reminders and policies that no longer apply
|
||||
transact.delete(
|
||||
key=KeyPair(
|
||||
pk=id,
|
||||
sk='CANCEL_POLICY',
|
||||
)
|
||||
)
|
||||
transact.delete(
|
||||
key=KeyPair(
|
||||
pk=id,
|
||||
@@ -282,6 +299,7 @@ def _set_status_as_failed(
|
||||
id: str,
|
||||
/,
|
||||
score: Decimal,
|
||||
progress: Decimal,
|
||||
user_id: str,
|
||||
course_id: str,
|
||||
*,
|
||||
@@ -293,14 +311,15 @@ def _set_status_as_failed(
|
||||
with dynamodb_persistence_layer.transact_writer() as transact:
|
||||
transact.update(
|
||||
key=KeyPair(pk=id, sk='0'),
|
||||
update_expr='SET #status = :failed, score = :score, \
|
||||
updated_at = :updated_at',
|
||||
update_expr='SET #status = :failed, progress = :progress, \
|
||||
score = :score, updated_at = :updated_at',
|
||||
cond_expr='#status = :in_progress',
|
||||
expr_attr_names={'#status': 'status'},
|
||||
expr_attr_values={
|
||||
':failed': 'FAILED',
|
||||
':in_progress': 'IN_PROGRESS',
|
||||
':score': score,
|
||||
':progress': progress,
|
||||
':updated_at': now_,
|
||||
},
|
||||
exc_cls=EnrollmentConflictError,
|
||||
@@ -314,6 +333,12 @@ def _set_status_as_failed(
|
||||
cond_expr='attribute_not_exists(sk)',
|
||||
)
|
||||
# Remove reminders and events that no longer apply
|
||||
transact.delete(
|
||||
key=KeyPair(
|
||||
pk=id,
|
||||
sk='CANCEL_POLICY',
|
||||
)
|
||||
)
|
||||
transact.delete(
|
||||
key=KeyPair(
|
||||
pk=id,
|
||||
@@ -413,6 +438,12 @@ def _set_status_as_expired(
|
||||
cond_expr='attribute_not_exists(sk)',
|
||||
)
|
||||
# Remove events and policies that no longer apply
|
||||
transact.delete(
|
||||
key=KeyPair(
|
||||
pk=id,
|
||||
sk='CANCEL_POLICY',
|
||||
),
|
||||
)
|
||||
transact.delete(
|
||||
key=KeyPair(
|
||||
pk=id,
|
||||
|
||||
Reference in New Issue
Block a user