import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

async function check() {
  const users = await prisma.user.findMany({ 
    include: { conversations: { include: { conversation: { include: { messages: true } } } } } 
  })
  console.log('Users and their conversation activity:')
  users.forEach(u => {
    console.log(`- User: ${u.name} (${u.id})`)
    const msgs = u.conversations.flatMap(c => c.conversation.messages)
    const unread = msgs.filter(m => m.senderId !== u.id && !m.read).length
    console.log(`  Unread messages for this user: ${unread}`)
  })
}

check()
