add enroll to subscribed

This commit is contained in:
2025-12-08 16:48:31 -03:00
parent 1ff2634bc0
commit 93d96486ff
11 changed files with 148 additions and 108 deletions

View File

@@ -40,8 +40,8 @@ class DeduplicationConflictError(ConflictError): ...
class User(BaseModel):
id: str | UUID4
name: NameStr
cpf: CpfStr
email: EmailStr
cpf: CpfStr
class Course(BaseModel):
@@ -123,9 +123,9 @@ def enroll(
Context = TypedDict(
'Context',
{
'created_by': Authenticated,
'org': Org,
'terms': SubscriptionTerms,
'created_by': Authenticated,
},
)
@@ -251,14 +251,12 @@ def enroll_later(enrollment: Enrollment, context: Context):
'sk': f'{scheduled_for.isoformat()}#{lock_hash}',
'user': user.model_dump(),
'course': course.model_dump(),
'org': org.model_dump(),
'org_name': org.name,
'created_by': {
'id': created_by.id,
'name': created_by.name,
},
'subscription_covered': {
'billing_day': subscription_terms.billing_day,
},
'subscription_billing_day': subscription_terms.billing_day,
'ttl': ttl(start_dt=scheduled_for),
'created_at': now_,
}

View File

@@ -16,8 +16,7 @@ dyn = DynamoDBPersistenceLayer(ENROLLMENT_TABLE, dynamodb_client)
@router.get('/<org_id>/enrollments/scheduled')
def scheduled(org_id: str, start_key: Annotated[str | None, Query] = None):
return dyn.collection.query(
# Post-migration: rename `scheduled_items` to `SCHEDULED#ORG#{org_id}`
key=PartitionKey(f'scheduled_items#{org_id}'),
key=PartitionKey(f'SCHEDULED#ORG#{org_id}'),
start_key=start_key,
limit=150,
)