mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
27 lines
814 B
Python
27 lines
814 B
Python
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
|
|
|
|
|
|
logger = setup_logger()
|
|
|
|
|
|
def handler(event: Mapping[str, Any], context: Any) -> None:
|
|
|
|
process_portfolio(556)
|
|
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}")
|