File size: 1,053 Bytes
5a6c225
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""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())