41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
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!);
|
|
|
|
async function dumpRecent() {
|
|
console.log('--- Dumping Last 10 Orders ---');
|
|
const { data: orders, error } = await supabase
|
|
.from('orders')
|
|
.select('*')
|
|
.order('timestamp', { ascending: false })
|
|
.limit(10);
|
|
|
|
if (error) {
|
|
console.error('Error:', error);
|
|
} else {
|
|
orders.forEach(o => {
|
|
console.log(`[Order] ID: ${o.order_id || o.id}, User: ${o.user_id}, Symbol: ${o.symbol}, Price: ${o.price}`);
|
|
});
|
|
}
|
|
|
|
console.log('\n--- Dumping Last 10 Trade History ---');
|
|
const { data: history, error: hErr } = await supabase
|
|
.from('trade_history')
|
|
.select('*')
|
|
.order('timestamp', { ascending: false })
|
|
.limit(10);
|
|
|
|
if (hErr) {
|
|
console.error('Error:', hErr);
|
|
} else {
|
|
history.forEach(h => {
|
|
console.log(`[History] User: ${h.user_id}, Symbol: ${h.symbol}, P&L: ${h.pnl}, Reason: ${h.reason}`);
|
|
});
|
|
}
|
|
}
|
|
|
|
dumpRecent();
|