Model/infrastructure/postgres/solar_table.py
Khalim Conn-Kowlessar 5a3be9d672 feat(ingestion): relocate EpcClientService to infrastructure + SolarRepo (#1133)
Move the EpcClientService package (client + _retry + exceptions + tests) from
the dying backend/ tree to infrastructure/epc_client/ as the New-EPC-API Fetcher;
update the two callers (address2UPRN, a script). All 14 client tests pass.

Add SolarRepository port + SolarPostgresRepository persisting Google Solar
building insights as JSONB (solar_building_insights table), one row per Property.
The EPC repo half of this slice already landed in #1129. pyright strict clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 16:28:48 +00:00

22 lines
847 B
Python

from __future__ import annotations
from typing import Any, ClassVar, Optional
from sqlalchemy import Column
from sqlalchemy.dialects.postgresql import JSONB
from sqlmodel import Field, SQLModel
class SolarBuildingInsightsRow(SQLModel, table=True):
"""Persisted Google Solar `buildingInsights` response for one Property.
Stored as JSONB — the raw fetched insights are retained whole so the
structured projection a future SolarPotential type needs can be derived
without re-fetching. One row per Property.
"""
__tablename__: ClassVar[str] = "solar_building_insights" # pyright: ignore[reportIncompatibleVariableOverride]
id: Optional[int] = Field(default=None, primary_key=True)
property_id: int = Field(index=True, unique=True)
insights: dict[str, Any] = Field(sa_column=Column(JSONB, nullable=False))