update batch
This commit is contained in:
@@ -125,6 +125,11 @@ def enroll(
|
||||
ttl_expiration = ttl(
|
||||
start_dt=now_ + timedelta(days=course.access_period - offset_days)
|
||||
)
|
||||
|
||||
class DeduplicationConflictError(Exception):
|
||||
def __init__(self, *args):
|
||||
super().__init__('Enrollment already exists')
|
||||
|
||||
transact.put(
|
||||
item={
|
||||
'id': 'lock',
|
||||
@@ -134,6 +139,7 @@ def enroll(
|
||||
'ttl': ttl_expiration,
|
||||
},
|
||||
cond_expr='attribute_not_exists(sk)',
|
||||
exc_cls=DeduplicationConflictError,
|
||||
)
|
||||
transact.put(
|
||||
item={
|
||||
|
||||
@@ -4,7 +4,6 @@ from typing import TypedDict
|
||||
from aws_lambda_powertools.event_handler.exceptions import (
|
||||
BadRequestError,
|
||||
)
|
||||
from botocore.tokens import timedelta
|
||||
from layercake.dateutils import now, ttl
|
||||
from layercake.dynamodb import (
|
||||
ComposeKey,
|
||||
|
||||
Reference in New Issue
Block a user