import sqlite3
import os

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

# 활성 배너 차량 확인
cursor.execute('SELECT id, car_id, is_active FROM hero_banners WHERE is_active = 1')
banners = cursor.fetchall()
print('=== Active Banners ===')
for b in banners:
    print(f'  Banner ID: {b[0]}, Car ID: {b[1]}')

print()

# 성능점검표 테이블 구조 확인
cursor.execute('PRAGMA table_info(car_performance_checks)')
columns = cursor.fetchall()
print('=== car_performance_checks Table Structure ===')
for col in columns:
    print(f'  {col[1]} ({col[2]})')

print()

# 배너 차량들의 성능점검표 확인
if banners:
    car_ids = [b[1] for b in banners if b[1]]
    if car_ids:
        placeholders = ','.join('?' * len(car_ids))
        cursor.execute(f'SELECT car_id, check_number FROM car_performance_checks WHERE car_id IN ({placeholders})', car_ids)
        perf_checks = cursor.fetchall()
        print('=== Performance Checks for Banner Cars ===')
        if perf_checks:
            for pc in perf_checks:
                print(f'  Car ID: {pc[0]}, Check #: {pc[1]}')
        else:
            print('  No performance checks found for banner cars!')

print()

# 전체 성능점검표 개수
cursor.execute('SELECT COUNT(*) FROM car_performance_checks')
count = cursor.fetchone()[0]
print(f'=== Total Performance Checks: {count} ===')

conn.close()
