mirror of
https://github.com/Sea-Haven-Industries/meal-order-manager.git
synced 2026-09-30 08:53:13 +00:00
Fix shared layer structure and DynamoDB Decimal type error (#2)
Move shared layer source from src/shared/python/shared/ to src/shared/shared/ to prevent SAM from creating a double python/python/ directory in the layer artifact. Add _to_decimal() helper to convert floats to Decimal for DynamoDB compatibility in put_order.
This commit is contained in:
parent
d332affd56
commit
360a0435e8
4 changed files with 9 additions and 2 deletions
|
|
@ -1,6 +1,8 @@
|
|||
import json
|
||||
import os
|
||||
import time
|
||||
from datetime import datetime
|
||||
from decimal import Decimal
|
||||
from zoneinfo import ZoneInfo
|
||||
from boto3.dynamodb.conditions import Key
|
||||
import boto3
|
||||
|
|
@ -63,8 +65,13 @@ def get_form_status(week: str) -> str:
|
|||
return menu.get("form_status", "closed")
|
||||
|
||||
|
||||
def _to_decimal(obj):
|
||||
"""Convert floats to Decimal for DynamoDB compatibility."""
|
||||
return json.loads(json.dumps(obj), parse_float=Decimal)
|
||||
|
||||
|
||||
def put_order(week: str, employee_slug: str, order_data: dict):
|
||||
_get_table().put_item(Item={
|
||||
_get_table().put_item(Item=_to_decimal({
|
||||
"PK": f"WEEK#{week}",
|
||||
"SK": f"ORDER#{employee_slug}",
|
||||
"employee_name": order_data["employee_name"],
|
||||
|
|
@ -73,7 +80,7 @@ def put_order(week: str, employee_slug: str, order_data: dict):
|
|||
"items": order_data["items"],
|
||||
"total": order_data["total"],
|
||||
"ttl": ttl_days(90),
|
||||
})
|
||||
}))
|
||||
|
||||
|
||||
def get_orders(week: str) -> list[dict]:
|
||||
Loading…
Add table
Reference in a new issue