This commit is contained in:
2025-10-14 23:38:39 -03:00
parent a7e5a0a528
commit 54c92b3996
11 changed files with 38 additions and 18 deletions

View File

@@ -9,11 +9,13 @@ from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair, SortKey
from boto3clients import dynamodb_client
from config import (
COURSE_TABLE,
ENROLLMENT_TABLE,
)
logger = Logger(__name__)
dyn = DynamoDBPersistenceLayer(ENROLLMENT_TABLE, dynamodb_client)
enrollment_layer = DynamoDBPersistenceLayer(ENROLLMENT_TABLE, dynamodb_client)
course_layer = DynamoDBPersistenceLayer(COURSE_TABLE, dynamodb_client)
@event_source(data_class=EventBridgeEvent)
@@ -28,7 +30,7 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
# Post-migration: after removing the stopgap file `patch_course_metadata.py`,
# use `access_expires_at` from `new_image`
access_period = int(
dyn.collection.get_item(
course_layer.collection.get_item(
KeyPair(
pk=new_image['course']['id'],
sk=SortKey('0', path_spec='access_period'),
@@ -36,7 +38,7 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
)
)
with dyn.transact_writer() as transact:
with enrollment_layer.transact_writer() as transact:
transact.put(
item={
'id': enrollment_id,

View File

@@ -26,7 +26,7 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
terms = user_layer.get_item(
# Post-migration (users): uncomment the following line
# KeyPair(new_image['org_id'], 'METADATA#BILLING_TERMS'),
KeyPair(new_image['tenant_id'], 'metadata#billing_policy'),
KeyPair(new_image['org_id'], 'metadata#billing_policy'),
)
if not terms: