48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
import asyncio
|
|
import json
|
|
from app.database import AsyncSessionLocal
|
|
from sqlalchemy import text
|
|
|
|
async def repair_cars():
|
|
async with AsyncSessionLocal() as db:
|
|
# Javított lekérdezés: make, model és year oszlopokat használunk name helyett
|
|
query = text("""
|
|
SELECT id, make, model, year, url
|
|
FROM vehicle.catalog_discovery
|
|
WHERE status = 'incomplete' OR status = 'pending'
|
|
ORDER BY id ASC
|
|
LIMIT 5
|
|
""")
|
|
try:
|
|
res = await db.execute(query)
|
|
cars = res.fetchall()
|
|
|
|
if not cars:
|
|
print("✨ Nincs több javítandó autó a listában!")
|
|
return
|
|
|
|
for car_id, make, model, year, url in cars:
|
|
full_name = f"{year} {make} {model}"
|
|
print(f"\n🚗 JÁRMŰ: {full_name}")
|
|
print(f"🔗 LINK: {url}")
|
|
print("-" * 30)
|
|
|
|
# Itt írhatod be a hiányzó adatokat
|
|
val = input("Írd be a műszaki adatokat (pl. '150 HP, 1998cc') vagy 'skip': ")
|
|
|
|
if val.lower() != 'skip':
|
|
# A JSONB mezőt frissítjük a kézi javítással
|
|
data_update = {"manual_fix": val}
|
|
await db.execute(text("""
|
|
UPDATE vehicle.catalog_discovery
|
|
SET raw_data = raw_data || :data, status = 'ready_for_catalog'
|
|
WHERE id = :id
|
|
"""), {"data": json.dumps(data_update), "id": car_id})
|
|
await db.commit()
|
|
print(f"✅ {full_name} mentve és kész a katalógusba tolásra!")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Hiba történt: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(repair_cars()) |