update table

This commit is contained in:
2025-12-13 00:14:24 -03:00
parent 72f049babd
commit a1c0e3dcd5
6 changed files with 191 additions and 95 deletions

View File

@@ -12,7 +12,7 @@ from layercake.funcs import pick
from boto3clients import dynamodb_client
from config import ENROLLMENT_TABLE
from enrollment import Enrollment, enroll
from enrollment import Enrollment, Subscription, enroll
logger = Logger(__name__)
dyn = DynamoDBPersistenceLayer(ENROLLMENT_TABLE, dynamodb_client)
@@ -33,6 +33,14 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
course=old_image['course'],
user=old_image['user'],
)
subscription: Subscription | None = (
{
'org_id': org_id,
'billing_day': int(billing_day),
}
if billing_day
else None
)
try:
enroll(
@@ -41,14 +49,8 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
'org_id': org_id,
'name': old_image['org_name'],
},
subscription=(
{
'org_id': org_id,
'billing_day': int(billing_day),
}
if billing_day
else None
),
subscription=subscription,
cancel_policy=bool(subscription),
created_by=created_by,
scheduled_at=datetime.fromisoformat(old_image['created_at']),
# Transfer the deduplication window if it exists