const { PrismaClient } = require('@prisma/client') const prisma = new PrismaClient() async function checkTradeCounts() { try { console.log('šŸ” Checking trade counts in database...') // Total trades const totalTrades = await prisma.trade.count({ where: { userId: 'default-user', symbol: 'SOLUSD' } }) // Completed trades const completedTrades = await prisma.trade.count({ where: { userId: 'default-user', symbol: 'SOLUSD', status: 'COMPLETED' } }) // Open/Active trades const activeTrades = await prisma.trade.count({ where: { userId: 'default-user', symbol: 'SOLUSD', status: 'OPEN' } }) // Pending trades const pendingTrades = await prisma.trade.count({ where: { userId: 'default-user', symbol: 'SOLUSD', status: 'PENDING' } }) console.log('\nšŸ“Š TRADE COUNTS:') console.log(`Total Trades: ${totalTrades}`) console.log(`Completed Trades: ${completedTrades}`) console.log(`Active Trades: ${activeTrades}`) console.log(`Pending Trades: ${pendingTrades}`) // Get all trades with details const allTrades = await prisma.trade.findMany({ where: { userId: 'default-user', symbol: 'SOLUSD' }, orderBy: { createdAt: 'desc' }, select: { id: true, side: true, amount: true, price: true, status: true, createdAt: true, leverage: true, profit: true } }) console.log('\nšŸ“‹ ALL TRADES:') allTrades.forEach((trade, index) => { console.log(`${index + 1}. ${trade.side} ${trade.amount} tokens @ $${trade.price} - ${trade.status} (${new Date(trade.createdAt).toLocaleString()})`) }) // Check automation sessions const sessions = await prisma.automationSession.count({ where: { userId: 'default-user', symbol: 'SOLUSD' } }) console.log(`\nšŸ¤– Automation Sessions: ${sessions}`) } catch (error) { console.error('Error checking trade counts:', error) } finally { await prisma.$disconnect() } } checkTradeCounts()