wip
This commit is contained in:
@@ -5,7 +5,7 @@ ORDER_TABLE: str = os.getenv('ORDER_TABLE') # type: ignore
|
||||
COURSE_TABLE: str = os.getenv('COURSE_TABLE') # type: ignore
|
||||
ENROLLMENT_TABLE: str = os.getenv('ENROLLMENT_TABLE') # type: ignore
|
||||
|
||||
# Post-migration: remove the lines below
|
||||
# Post-migration: Remove the following lines
|
||||
if os.getenv('AWS_LAMBDA_FUNCTION_NAME'):
|
||||
SQLITE_DATABASE = 'courses_export_2025-06-18_110214.db'
|
||||
else:
|
||||
|
||||
@@ -64,4 +64,6 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
},
|
||||
)
|
||||
|
||||
logger.info('IDs updated')
|
||||
|
||||
return True
|
||||
|
||||
@@ -32,7 +32,7 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
|
||||
result = enrollment_layer.collection.query(
|
||||
KeyPair(
|
||||
# Post-migration: uncomment the following line
|
||||
# Post-migration: Uncomment the following line
|
||||
# ComposeKey(tenant_id, prefix='slots#org'),
|
||||
ComposeKey(tenant_id, prefix='vacancies'),
|
||||
order_id,
|
||||
@@ -45,10 +45,12 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
for pair in result['items']:
|
||||
batch.delete_item(
|
||||
Key={
|
||||
# Post-migration: rename `vacancies` to `slots#org`
|
||||
# Post-migration: Rename `vacancies` to `slots#org`
|
||||
'id': {'S': ComposeKey(pair['id'], prefix='vacancies')},
|
||||
'sk': {'S': pair['sk']},
|
||||
}
|
||||
)
|
||||
|
||||
logger.info('Slots deleted')
|
||||
|
||||
return True
|
||||
|
||||
@@ -6,6 +6,7 @@ from aws_lambda_powertools.utilities.data_classes import (
|
||||
from aws_lambda_powertools.utilities.typing import LambdaContext
|
||||
from layercake.dateutils import now
|
||||
from layercake.dynamodb import (
|
||||
ComposeKey,
|
||||
DynamoDBPersistenceLayer,
|
||||
KeyPair,
|
||||
)
|
||||
@@ -41,7 +42,23 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
)
|
||||
except Exception:
|
||||
logger.info('Failed to update status to EXPIRED', order_id=new_image['id'])
|
||||
order_layer.put_item(
|
||||
item={
|
||||
'id': new_image['id'],
|
||||
'sk': ComposeKey('failed', prefix=new_image['sk']),
|
||||
'created_at': now_,
|
||||
}
|
||||
)
|
||||
|
||||
return False
|
||||
else:
|
||||
logger.info('Status set to EXPIRED', order_id=new_image['id'])
|
||||
order_layer.put_item(
|
||||
item={
|
||||
'id': new_image['id'],
|
||||
'sk': ComposeKey('completed', prefix=new_image['sk']),
|
||||
'created_at': now_,
|
||||
}
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import json
|
||||
import sqlite3
|
||||
from decimal import ROUND_HALF_UP, Decimal
|
||||
|
||||
from aws_lambda_powertools import Logger
|
||||
from aws_lambda_powertools.utilities.data_classes import (
|
||||
@@ -33,9 +34,15 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
|
||||
for item in items:
|
||||
course = _get_course(item['id'])
|
||||
unit_price = Decimal(item['unit_price'])
|
||||
|
||||
new_items.append(
|
||||
item
|
||||
| {
|
||||
'unit_price': unit_price.quantize(
|
||||
Decimal('0.01'), rounding=ROUND_HALF_UP
|
||||
)
|
||||
}
|
||||
| (
|
||||
{
|
||||
'id': course.get('metadata__betaeducacao_id'),
|
||||
|
||||
Reference in New Issue
Block a user