meal-order-manager/functions/close_form/handler.py

27 lines
619 B
Python
Raw Normal View History

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}