mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
implement handler
This commit is contained in:
parent
827745c10f
commit
35f7738160
1 changed files with 17 additions and 1 deletions
|
|
@ -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}")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue