mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
35 lines
995 B
Python
35 lines
995 B
Python
import asyncio
|
|
import json
|
|
from typing import Mapping, Any
|
|
from io import BytesIO
|
|
|
|
from backend.condition.condition_trigger_request import ConditionTriggerRequest
|
|
from backend.condition.lookups.uprn_lookup_s3 import UprnLookupS3
|
|
from utils.logger import setup_logger
|
|
from backend.condition.processor import process_file
|
|
|
|
|
|
logger = setup_logger()
|
|
|
|
|
|
def handler(event: Mapping[str, Any], context: Any) -> None:
|
|
# Temporary stub for PoC wiring
|
|
uprn_lookup = UprnLookupS3(
|
|
bucket="", key=""
|
|
) # TODO: replace with postgres implementation
|
|
|
|
for record in event.get("Records", []):
|
|
try:
|
|
body_dict = json.loads(record["body"])
|
|
payload = ConditionTriggerRequest.model_validate(body_dict)
|
|
|
|
# fetch file from s3
|
|
|
|
# open file and send bytes to processor
|
|
|
|
except Exception as e:
|
|
logger.error(f"Failed to process record: {e}")
|
|
|
|
# dummy_stream = BytesIO(b"")
|
|
|
|
# process_file(dummy_stream, source_key)
|