add set as expired

This commit is contained in:
2025-08-22 18:04:21 -03:00
parent 45f444a222
commit 4acf85fd85
17 changed files with 87 additions and 53 deletions

View File

@@ -1,5 +1,3 @@
from datetime import timedelta
from aws_lambda_powertools import Logger
from aws_lambda_powertools.utilities.data_classes import (
EventBridgeEvent,
@@ -15,7 +13,7 @@ from config import (
)
logger = Logger(__name__)
enrollment_layer = DynamoDBPersistenceLayer(ENROLLMENT_TABLE, dynamodb_client)
dyn = DynamoDBPersistenceLayer(ENROLLMENT_TABLE, dynamodb_client)
@event_source(data_class=EventBridgeEvent)
@@ -27,7 +25,7 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
course = new_image['course']
now_ = now()
with enrollment_layer.transact_writer() as transact:
with dyn.transact_writer() as transact:
transact.put(
item={
'id': enrollment_id,
@@ -48,22 +46,19 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
item={
'id': enrollment_id,
'sk': 'SCHEDULE#SET_AS_EXPIRED',
'name': user.name,
'email': user.email,
'course': course.name,
'created_at': now_,
'ttl': ttl(start_dt=now_ + timedelta(days=course.access_period)),
'ttl': ttl(start_dt=now_, days=course.access_period),
},
)
transact.put(
item={
'id': enrollment_id,
'sk': 'REMINDER_ACCESS_PERIOD_BEFORE_15_DAYS',
'sk': 'SCHEDULE#REMINDER_CERT_EXPIRATION_BEFORE_30_DAYS',
'name': user.name,
'email': user.email,
'course': course.name,
'created_at': now_,
'ttl': ttl(start_dt=now_ + timedelta(days=course.access_period - 15)),
'ttl': ttl(start_dt=now_, days=course.access_period - 30),
},
)