remove deduplication as default
This commit is contained in:
@@ -9,7 +9,7 @@ from layercake.dateutils import now, ttl
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair, SortKey, TransactKey
|
||||
from layercake.strutils import md5_hash
|
||||
|
||||
from config import COURSE_TABLE
|
||||
from config import COURSE_TABLE, DEDUP_WINDOW_OFFSET_DAYS
|
||||
|
||||
logger = Logger(__name__)
|
||||
|
||||
@@ -117,7 +117,9 @@ def set_score(
|
||||
)
|
||||
user_id = enrollment['user']['id']
|
||||
course_id = enrollment['course']['id']
|
||||
dedup_window_offset_days = int(enrollment['dedup_window_offset_days'])
|
||||
dedup_window_offset_days = int(
|
||||
enrollment.get('dedup_window_offset_days', DEDUP_WINDOW_OFFSET_DAYS)
|
||||
)
|
||||
|
||||
try:
|
||||
if score >= 70:
|
||||
@@ -159,7 +161,7 @@ def _set_status_as_completed(
|
||||
) -> bool:
|
||||
now_ = now()
|
||||
lock_hash = md5_hash(f'{user_id}{course_id}')
|
||||
exp_interval = int(
|
||||
cert_exp_interval = int(
|
||||
dynamodb_persistence_layer.collection.get_item(
|
||||
KeyPair(
|
||||
pk=course_id,
|
||||
@@ -191,17 +193,17 @@ def _set_status_as_completed(
|
||||
exc_cls=EnrollmentConflictError,
|
||||
)
|
||||
|
||||
if exp_interval:
|
||||
if cert_exp_interval:
|
||||
dedup_lock_ttl = ttl(
|
||||
start_dt=now_,
|
||||
days=exp_interval - dedup_window_offset_days,
|
||||
days=cert_exp_interval - dedup_window_offset_days,
|
||||
)
|
||||
|
||||
transact.put(
|
||||
item={
|
||||
'id': id,
|
||||
'sk': 'SCHEDULE#SET_CERT_EXPIRED',
|
||||
'ttl': ttl(start_dt=now_, days=exp_interval),
|
||||
'ttl': ttl(start_dt=now_, days=cert_exp_interval),
|
||||
'created_at': now_,
|
||||
}
|
||||
)
|
||||
@@ -209,7 +211,7 @@ def _set_status_as_completed(
|
||||
item={
|
||||
'id': id,
|
||||
'sk': 'SCHEDULE#REMINDER_CERT_EXPIRATION_BEFORE_30_DAYS',
|
||||
'ttl': ttl(start_dt=now_, days=exp_interval - 30),
|
||||
'ttl': ttl(start_dt=now_, days=cert_exp_interval - 30),
|
||||
'created_at': now_,
|
||||
}
|
||||
)
|
||||
@@ -231,6 +233,23 @@ def _set_status_as_completed(
|
||||
'created_at': now_,
|
||||
}
|
||||
)
|
||||
else:
|
||||
transact.put(
|
||||
item={
|
||||
'id': id,
|
||||
'sk': 'LOCK',
|
||||
'hash': lock_hash,
|
||||
'created_at': now_,
|
||||
}
|
||||
)
|
||||
transact.put(
|
||||
item={
|
||||
'id': 'LOCK',
|
||||
'sk': lock_hash,
|
||||
'enrollment_id': id,
|
||||
'created_at': now_,
|
||||
}
|
||||
)
|
||||
|
||||
# Remove reminders and policies that no longer apply
|
||||
transact.delete(
|
||||
|
||||
Reference in New Issue
Block a user