"""Check banner cars and their source_id for fetching performance checks""" import sqlite3 import os os.chdir(r'D:\Workspace\claudeCode\AutonetSellCar.com\backend') conn = sqlite3.connect('autonet.db') cursor = conn.cursor() # 먼저 cars 테이블 구조 확인 cursor.execute('PRAGMA table_info(cars)') columns = cursor.fetchall() print('=== cars Table Columns ===') col_names = [col[1] for col in columns] print(col_names) print() # 배너 차량들의 source_id 확인 cursor.execute(''' SELECT h.car_id, c.source_id, (SELECT COUNT(*) FROM car_performance_checks WHERE car_id = h.car_id) as has_perf FROM hero_banners h JOIN cars c ON h.car_id = c.id WHERE h.is_active = 1 ''') banner_cars = cursor.fetchall() print('=== Banner Cars Status ===') print() cars_without_perf = [] for car in banner_cars: car_id, source_id, has_perf = car status = 'O' if has_perf > 0 else 'X' print(f'Car ID: {car_id}, Source ID: {source_id}, Perf Check: {status}') if has_perf == 0 and source_id: cars_without_perf.append((car_id, source_id)) print() print('=== Cars that need performance check fetch ===') for car_id, source_id in cars_without_perf: print(f' Car ID: {car_id}, Source ID: {source_id}') conn.close()