AIDA / fix_failed_listing.py
destinyebuka's picture
fyp
5a6c225
"""Fix the one failed listing by geocoding just the city"""
import asyncio
from app.database import connect_db, get_db
from app.ai.tools.listing_tool import geocode_address
from bson import ObjectId
async def fix_failed_listing():
await connect_db()
db = await get_db()
# Find the specific listing
listing_id = "694402f3947fa344b4462fce"
print("πŸ” Geocoding Cotonou (city only)...")
geo_result = await geocode_address("Cotonou", None)
if geo_result.get("success"):
lat = geo_result.get("latitude")
lon = geo_result.get("longitude")
result = await db.listings.update_one(
{"_id": ObjectId(listing_id)},
{"$set": {"latitude": lat, "longitude": lon}}
)
if result.modified_count > 0:
print(f"βœ… Updated: lat={lat}, lon={lon}")
else:
print("⚠️ No change made")
else:
print(f"❌ Failed: {geo_result.get('error')}")
if __name__ == "__main__":
asyncio.run(fix_failed_listing())