update
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
import os
|
||||
|
||||
USER_TABLE: str = os.getenv('USER_TABLE') # type: ignore
|
||||
ORDER_TABLE: str = os.getenv('ORDER_TABLE') # type: ignore
|
||||
ENROLLMENT_TABLE: str = os.getenv('ENROLLMENT_TABLE') # type: ignore
|
||||
@@ -13,7 +13,7 @@ from layercake.dynamodb import (
|
||||
)
|
||||
|
||||
from boto3clients import dynamodb_client
|
||||
from conf import ORDER_TABLE, USER_TABLE
|
||||
from config import ORDER_TABLE, USER_TABLE
|
||||
|
||||
logger = Logger(__name__)
|
||||
user_layer = DynamoDBPersistenceLayer(USER_TABLE, dynamodb_client)
|
||||
@@ -39,7 +39,7 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
flatten_top=False,
|
||||
)
|
||||
|
||||
# Sometimes, a DynamoDB insertion may take longer to complete,
|
||||
# Sometimes the function executes before the user insertion completes,
|
||||
# so an exception is raised to trigger a retry.
|
||||
if len(ids) < 2:
|
||||
raise ValueError('IDs not found.')
|
||||
|
||||
@@ -9,7 +9,7 @@ from layercake.dynamodb import (
|
||||
)
|
||||
|
||||
from boto3clients import dynamodb_client
|
||||
from conf import ORDER_TABLE, USER_TABLE
|
||||
from config import ORDER_TABLE, USER_TABLE
|
||||
|
||||
logger = Logger(__name__)
|
||||
user_layer = DynamoDBPersistenceLayer(USER_TABLE, dynamodb_client)
|
||||
|
||||
@@ -8,10 +8,11 @@ from layercake.dateutils import now
|
||||
from layercake.dynamodb import (
|
||||
DynamoDBPersistenceLayer,
|
||||
KeyPair,
|
||||
TransactItems,
|
||||
)
|
||||
|
||||
from boto3clients import dynamodb_client
|
||||
from conf import ORDER_TABLE
|
||||
from config import ORDER_TABLE
|
||||
|
||||
logger = Logger(__name__)
|
||||
order_layer = DynamoDBPersistenceLayer(ORDER_TABLE, dynamodb_client)
|
||||
@@ -21,7 +22,9 @@ order_layer = DynamoDBPersistenceLayer(ORDER_TABLE, dynamodb_client)
|
||||
@logger.inject_lambda_context
|
||||
def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
new_image = event.detail['new_image']
|
||||
order_layer.update_item(
|
||||
now_ = now()
|
||||
transact = TransactItems(order_layer.table_name)
|
||||
transact.update(
|
||||
key=KeyPair(new_image['id'], '0'),
|
||||
update_expr='SET #status = :status, update_date = :update_date',
|
||||
expr_attr_names={
|
||||
@@ -29,8 +32,15 @@ def lambda_handler(event: EventBridgeEvent, context: LambdaContext) -> bool:
|
||||
},
|
||||
expr_attr_values={
|
||||
':status': 'PAID',
|
||||
':update_date': now(),
|
||||
':update_date': now_,
|
||||
},
|
||||
)
|
||||
|
||||
transact.put(
|
||||
item={
|
||||
'id': new_image['id'],
|
||||
'sk': 'paid_date',
|
||||
'create_date': now_,
|
||||
}
|
||||
)
|
||||
order_layer.transact_write_items(transact)
|
||||
return True
|
||||
|
||||
@@ -111,5 +111,5 @@ Resources:
|
||||
cnpj:
|
||||
- exists: true
|
||||
total: [0]
|
||||
status: [PENDING]
|
||||
status: [CREATING, PENDING]
|
||||
payment_method: [MANUAL]
|
||||
|
||||
Reference in New Issue
Block a user