"""Check PDF migration status"""
import sqlite3
import os

os.chdir(r'D:\Workspace\claudeCode\AutonetSellCar.com\backend')
conn = sqlite3.connect('autonet.db')
cursor = conn.cursor()

# Check total records
cursor.execute('SELECT COUNT(*) FROM car_performance_checks')
total = cursor.fetchone()[0]

# Check records with check_number
cursor.execute("SELECT COUNT(*) FROM car_performance_checks WHERE check_number IS NOT NULL AND check_number != ''")
with_check_num = cursor.fetchone()[0]

# Check records with pdf_path
cursor.execute("SELECT COUNT(*) FROM car_performance_checks WHERE pdf_path IS NOT NULL AND pdf_path != ''")
with_pdf = cursor.fetchone()[0]

print("=== Performance Check PDF Status ===")
print(f"Total records: {total}")
print(f"With check_number: {with_check_num}")
print(f"With PDF: {with_pdf}")
print(f"Pending PDF generation: {with_check_num - with_pdf}")

print()

# Show details
cursor.execute("SELECT car_id, check_number, pdf_path FROM car_performance_checks")
records = cursor.fetchall()
print("=== Details ===")
for r in records:
    car_id, check_num, pdf_path = r
    status = "O" if pdf_path else "X"
    print(f"Car ID: {car_id}, Check#: {check_num}, PDF: {status}")
    if pdf_path:
        print(f"  -> {pdf_path}")

conn.close()
