feat: separate sql
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
"""Image endpoints – retrieve photo URLs from the raw Funda data."""
|
||||
"""Image endpoints – retrieve photo URLs from listing data."""
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from fastapi import APIRouter, Depends
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.config import settings
|
||||
from app.config import load_sql
|
||||
from app.database import get_db
|
||||
|
||||
router = APIRouter()
|
||||
@@ -15,15 +15,8 @@ def get_listing_images(
|
||||
global_id: str,
|
||||
db: Session = Depends(get_db),
|
||||
) -> dict[str, list[str]]:
|
||||
"""Return image URLs for a listing from the raw Funda JSON data."""
|
||||
row = db.execute(
|
||||
text(
|
||||
"SELECT raw_json->'photo_urls' AS photo_urls "
|
||||
"FROM raw_funda.listing_details "
|
||||
"WHERE global_id = :gid"
|
||||
),
|
||||
{"gid": global_id},
|
||||
).first()
|
||||
"""Return image URLs for a listing."""
|
||||
row = db.execute(text(load_sql("listing_images.sql")), {"gid": global_id}).first()
|
||||
|
||||
if not row or not row.photo_urls:
|
||||
return {"images": []}
|
||||
|
||||
Reference in New Issue
Block a user