mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Any, ClassVar, Optional
|
|
|
|
from sqlalchemy import BigInteger, Column, Float
|
|
from sqlalchemy.dialects.postgresql import JSONB
|
|
from sqlmodel import Field, SQLModel
|
|
|
|
|
|
class SolarRow(SQLModel, table=True):
|
|
"""Mirror of the live ``solar`` table (owned by the Drizzle schema): the raw
|
|
Google Solar ``buildingInsights`` response for one UPRN, stored whole as
|
|
JSONB so a future SolarPotential projection can be derived without
|
|
re-fetching. Keyed by ``uprn`` (the live table carries no ``property_id``);
|
|
``longitude``/``latitude`` are the coordinates the fetch was made against.
|
|
|
|
Only the columns this repo reads/writes are mirrored — ``created_at`` /
|
|
``updated_at`` are left to the database's ``DEFAULT now()``.
|
|
"""
|
|
|
|
__tablename__: ClassVar[str] = "solar" # pyright: ignore[reportIncompatibleVariableOverride]
|
|
|
|
id: Optional[int] = Field(
|
|
default=None, sa_column=Column(BigInteger, primary_key=True)
|
|
)
|
|
uprn: int = Field(sa_column=Column(BigInteger, nullable=False, index=True))
|
|
longitude: float = Field(sa_column=Column(Float, nullable=False))
|
|
latitude: float = Field(sa_column=Column(Float, nullable=False))
|
|
google_api_response: dict[str, Any] = Field(
|
|
sa_column=Column(JSONB, nullable=False)
|
|
)
|