update slots
This commit is contained in:
38
http-api/app/routes/enrollments/slots.py
Normal file
38
http-api/app/routes/enrollments/slots.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
from aws_lambda_powertools.event_handler.api_gateway import Router
|
||||||
|
from layercake.dynamodb import (
|
||||||
|
ComposeKey,
|
||||||
|
DynamoDBPersistenceLayer,
|
||||||
|
PartitionKey,
|
||||||
|
)
|
||||||
|
|
||||||
|
from boto3clients import dynamodb_client
|
||||||
|
from config import (
|
||||||
|
ENROLLMENT_TABLE,
|
||||||
|
USER_TABLE,
|
||||||
|
)
|
||||||
|
from middlewares import Tenant, TenantMiddleware
|
||||||
|
|
||||||
|
router = Router()
|
||||||
|
|
||||||
|
enrollment_layer = DynamoDBPersistenceLayer(ENROLLMENT_TABLE, dynamodb_client)
|
||||||
|
user_layer = DynamoDBPersistenceLayer(USER_TABLE, dynamodb_client)
|
||||||
|
|
||||||
|
|
||||||
|
@router.get(
|
||||||
|
'/slots',
|
||||||
|
compress=True,
|
||||||
|
tags=['Enrollment'],
|
||||||
|
middlewares=[
|
||||||
|
TenantMiddleware(user_layer.collection),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def get_vacancies():
|
||||||
|
tenant: Tenant = router.context['tenant']
|
||||||
|
|
||||||
|
return enrollment_layer.collection.query(
|
||||||
|
PartitionKey(
|
||||||
|
# Post-migration: uncomment the following line
|
||||||
|
# ComposeKey(str(tenant.id), prefix='slots#orgs'),
|
||||||
|
ComposeKey(str(tenant.id), prefix='vacancies'),
|
||||||
|
)
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user