chore: Backend codebase cleanup and archiving of legacy scripts

This commit is contained in:
Roo
2026-03-22 20:07:37 +00:00
parent 5d96b00f81
commit 309a72cc0b
19 changed files with 530 additions and 184 deletions

View File

@@ -0,0 +1,32 @@
import asyncio
import httpx
from sqlalchemy import text
from app.db.session import SessionLocal
async def seed():
print("🚀 RDW Márka-felfedezés indul...")
url = "https://opendata.rdw.nl/resource/m9d7-ebf2.json?$select=distinct%20merk&$limit=50000"
async with httpx.AsyncClient() as client:
resp = await client.get(url, timeout=60)
if resp.status_code != 200:
print(f"❌ Hiba: {resp.status_code}")
return
makes = resp.json()
print(f"📦 {len(makes)} márkát találtam. Mentés...")
async with SessionLocal() as db:
for item in makes:
m = item['merk'].upper()
# ON CONFLICT: Ha már benne van (pl. n8n betette), ne legyen hiba
await db.execute(text("""
INSERT INTO data.catalog_discovery (make, model, source, status)
VALUES (:m, 'ALL', 'global_seed', 'pending')
ON CONFLICT DO NOTHING
"""), {"m": m})
await db.commit()
print("✅ Kész! A discovery tábla felöltve az összes EU-s márkával.")
if __name__ == "__main__":
asyncio.run(seed())