implement handler

This commit is contained in:
Daniel Roth 2026-02-17 09:33:31 +00:00
parent 827745c10f
commit 35f7738160

View file

@ -1,4 +1,9 @@
import json
from typing import Any, Mapping
from backend.categorisation.categorisation_trigger_request import (
CategorisationTriggerRequest,
)
from backend.categorisation.processor import process_portfolio
from utils.logger import setup_logger
@ -7,4 +12,15 @@ logger = setup_logger()
def handler(event: Mapping[str, Any], context: Any) -> None:
pass
for record in event.get("Records", []):
try:
body_dict = json.loads(record["body"])
logger.debug("Validating request body")
payload = CategorisationTriggerRequest.model_validate(body_dict)
logger.debug("Successfully validated request body")
process_portfolio(payload.portfolio_id)
except Exception as e:
logger.error(f"Failed to process record: {e}")