meal-order-manager/src/server/jobs/close_form.py
Adam Moussa f48a82c476
Some checks are pending
Deploy API / Resolve target (push) Waiting to run
Deploy API / Deploy API to (push) Blocked by required conditions
feat(api): serve meals on ECS Fargate instead of Lambda (PLAT-215) (#199)
* feat(api): serve meals on ECS Fargate instead of Lambda

Keep the Flask app always-on with in-process jobs so CloudFront no longer fronts a cold-start API Gateway.

* fix(jobs): run delayed close and reminder deliveries

Wall-clock skip windows dropped the only weekly SQS attempt when Scheduler already fired in Eastern time. Dev schedules stay disabled.

* fix(api): return JSON objects and stop logging job payloads

Flask now jsonify-s handler dicts so API responses are not HTML, and the worker logs only event and status.

* fix(ci): restore the reusable workflow so the required check is named ci / ci

Inlining the job reported `ci` instead of the org ruleset's `ci / ci`.

* fix(secrets): drop unused os import so ruff check passes

* style: apply ruff format so ci-python-app lint passes

* fix(infra): give meals its own VPC because prod has none

* chore(security): re-key ALB SG checkov suppression after vpc.tf
2026-09-21 19:34:24 +00:00

24 lines
752 B
Python

from shared.db import current_week, get_form_status, set_form_status
def _dispatch_job(payload: dict) -> None:
from server.jobs import enqueue_job
enqueue_job(payload)
def lambda_handler(event, context):
# Scheduler fires Thursday 23:59 America/New_York. Do not skip on wall
# clock: a delayed SQS delivery must still close the week. already-closed
# is the idempotency gate for redelivery.
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")
_dispatch_job({"event": "aggregate", "week": week})
return {"status": "closed", "week": week, "aggregate_triggered": True}