mirror of
https://github.com/Sea-Haven-Industries/meal-order-manager.git
synced 2026-10-01 12:53:12 +00:00
27 lines
619 B
Python
27 lines
619 B
Python
|
|
import json
|
||
|
|
import os
|
||
|
|
|
||
|
|
import boto3
|
||
|
|
|
||
|
|
from shared.db import current_week, get_form_status, set_form_status
|
||
|
|
|
||
|
|
_lambda = boto3.client("lambda")
|
||
|
|
|
||
|
|
|
||
|
|
def lambda_handler(event, context):
|
||
|
|
week = event.get("week", current_week())
|
||
|
|
|
||
|
|
status = get_form_status(week)
|
||
|
|
if status == "closed":
|
||
|
|
return {"status": "already_closed", "week": week}
|
||
|
|
|
||
|
|
set_form_status(week, "closed")
|
||
|
|
|
||
|
|
_lambda.invoke(
|
||
|
|
FunctionName=os.environ["AGGREGATE_FUNCTION_ARN"],
|
||
|
|
InvocationType="Event",
|
||
|
|
Payload=json.dumps({"week": week}),
|
||
|
|
)
|
||
|
|
|
||
|
|
return {"status": "closed", "week": week, "aggregate_triggered": True}
|