import { createClient } from '@supabase/supabase-js';
import * as dotenv from 'dotenv';
import path from 'path';

dotenv.config({ path: path.resolve(process.cwd(), '.env') });
const supabase = createClient(process.env.SUPABASE_URL!, process.env.SUPABASE_KEY!);

const userId = '8d5efd9e-0760-4859-8c07-0930ab3ede5a';

async function listAllHistory() {
    console.log(`--- Trade History for ${userId} ---`);
    const { data, error } = await supabase
        .from('trade_history')
        .select('*')
        .eq('user_id', userId)
        .order('created_at', { ascending: false });

    if (error) {
        console.error('Error:', error);
    } else {
        data.forEach(h => {
            console.log(`[History] Time: ${h.created_at}, Symbol: ${h.symbol}, Reason: ${h.reason}, P&L: ${h.pnl}`);
        });
    }
}

listAllHistory();
