
import sqlite3
import pandas as pd

match_id = 'g161-n-20251222204652101389654'

def check_data():
    conn = sqlite3.connect('database/L2/L2_Main.sqlite')
    
    print(f"--- Check Match: {match_id} ---")
    
    # 1. Source Type
    c = conn.cursor()
    c.execute("SELECT data_source_type FROM fact_matches WHERE match_id = ?", (match_id,))
    row = c.fetchone()
    if row:
        print(f"Data Source: {row[0]}")
    else:
        print("Match not found")
        return

    # 2. Round Events (Sample)
    print("\n--- Round Events Sample ---")
    try:
        df = pd.read_sql(f"SELECT round_num, event_type, attacker_steam_id, victim_steam_id, weapon FROM fact_round_events WHERE match_id = '{match_id}' LIMIT 5", conn)
        print(df)
        if df.empty:
            print("WARNING: No events found.")
    except Exception as e:
        print(e)

    # 3. Economy (Sample)
    print("\n--- Economy Sample ---")
    try:
        df_eco = pd.read_sql(f"SELECT round_num, steam_id_64, equipment_value FROM fact_round_player_economy WHERE match_id = '{match_id}' LIMIT 5", conn)
        print(df_eco)
        if df_eco.empty:
            print("Info: No economy data (Likely Classic source).")
    except Exception as e:
        print(e)
        
    conn.close()

if __name__ == "__main__":
    check_data()
