Verified catalogue of mobiles and laptops sold in India, collected from real retail listings (FastAPI backend, React frontend, Postgres/pgvector). - REST API under /api/elec (read-only catalogue; admin endpoints need login) - MCP server (FastMCP) at /mcp/ with list_categories, search_products, get_product and price_history tools - Real ratings and reviews read from product pages and search results - Production Dockerfile (requirements-api.txt, no PyTorch) and .env.production.example; remote database only via an explicit ELEC_ALLOW_REMOTE_DB host/name allowlist - docs/API.md: endpoint and MCP reference with live examples Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
"""Diagnostic: laptop products, their sites, and listings left unlinked."""
|
|
from app.electronics.db.connection import connect
|
|
|
|
with connect() as c:
|
|
rows = c.execute(
|
|
"""
|
|
SELECT p.variant_key, p.verification_status AS v, string_agg(s.name, ', ') AS sites
|
|
FROM elec.product p
|
|
JOIN elec.category ca ON ca.id = p.category_id AND ca.slug = 'laptops'
|
|
LEFT JOIN elec.product_listing_map m ON m.product_id = p.id
|
|
LEFT JOIN elec.source_listing l ON l.id = m.listing_id
|
|
LEFT JOIN elec.site s ON s.id = l.site_id
|
|
GROUP BY 1, 2 ORDER BY 1
|
|
"""
|
|
).fetchall()
|
|
for r in rows:
|
|
print(f"{r['v'][:5]:5} {r['variant_key']:60} | {r['sites']}")
|
|
print("\nUnlinked:")
|
|
for r in c.execute(
|
|
"""
|
|
SELECT s.name, l.title FROM elec.source_listing l JOIN elec.site s ON s.id = l.site_id
|
|
JOIN elec.category ca ON ca.id = l.category_id AND ca.slug = 'laptops'
|
|
WHERE NOT EXISTS (SELECT 1 FROM elec.product_listing_map m WHERE m.listing_id = l.id)
|
|
"""
|
|
):
|
|
print(f" {r['name'][:12]:12} {r['title'][:120]}".encode("ascii", "replace").decode())
|