backend env updates and brand json files

This commit is contained in:
sriram
2026-08-14 12:14:58 +05:30
parent 21c675cb55
commit 1b56aae396
7 changed files with 1069 additions and 10 deletions

View File

@@ -579,10 +579,16 @@ def get_brand_overview(force_refresh: bool = False) -> List[Dict[str, Any]]:
img = None
image_cols = [c for c in ("image_id", "image_url", "image_urls") if c in columns]
if "image_url" in columns or "image_urls" in columns:
where = " OR ".join(
f"({c} IS NOT NULL)" for c in ("image_url", "image_urls") if c in columns
)
url_cols = [c for c in ("image_url", "image_urls") if c in columns]
# Prefer a row that carries a stored URL. When the table has
# no URL column at all, still pick a row with an image_id:
# the router resolves that against S3 (brands.py), so the
# card gets an image instead of falling back to initials.
# Brand tables written by a different DDL really can lack
# both URL columns while their objects sit in the bucket.
filter_cols = url_cols or [c for c in image_cols if c == "image_id"]
if filter_cols:
where = " OR ".join(f"({c} IS NOT NULL)" for c in filter_cols)
order = " ORDER BY updated_at DESC" if "updated_at" in columns else ""
cur.execute(
f"SELECT {', '.join(image_cols)} FROM {table_name} "