#!/usr/bin/env python3
"""
Verify restaurant contact information has been populated
"""

from sqlalchemy import create_engine, text
from urllib.parse import quote_plus

def check_restaurant_contacts():
    DATABASE_URL = f"postgresql://postgres:{quote_plus('F@f@k0s!!')}@localhost:5432/bookbeach"
    engine = create_engine(DATABASE_URL)
    
    with engine.connect() as db:
        # Check total restaurants
        total_result = db.execute(text("SELECT COUNT(*) FROM restaurants")).fetchone()
        total_restaurants = total_result[0] if total_result else 0
        
        # Check restaurants with contact info
        contact_result = db.execute(text("""
            SELECT COUNT(*) FROM restaurants 
            WHERE phone IS NOT NULL AND phone != ''
            AND email IS NOT NULL AND email != ''
            AND website IS NOT NULL AND website != ''
        """)).fetchone()
        with_contact = contact_result[0] if contact_result else 0
        
        # Show some sample records
        samples = db.execute(text("""
            SELECT restaurant_name, phone, email, website
            FROM restaurants 
            WHERE phone IS NOT NULL AND email IS NOT NULL AND website IS NOT NULL
            ORDER BY restaurant_name
            LIMIT 5
        """)).fetchall()
        
        print(f"\n📊 Restaurant Contact Information Status:")
        print(f"Total restaurants: {total_restaurants}")
        print(f"Restaurants with full contact info: {with_contact}")
        print(f"Coverage: {(with_contact/total_restaurants*100):.1f}%\n")
        
        print("📋 Sample records:")
        for sample in samples:
            print(f"  {sample.restaurant_name}")
            print(f"    📞 {sample.phone}")
            print(f"    📧 {sample.email}")
            print(f"    🌐 {sample.website}")
            print()

if __name__ == '__main__':
    check_restaurant_contacts()