import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()

async function main() {
  const users = await prisma.user.findMany({
    include: {
      aiSettings: true,
      notes: {
        take: 5,
        orderBy: { updatedAt: 'desc' }
      }
    }
  })

  console.log('Total Users:', users.length)

  for (const user of users) {
    console.log(`User: ${user.email} (${user.id})`)
    console.log(`  AI Settings:`, user.aiSettings)
    console.log(`  Recent 5 Notes:`)
    for (const note of user.notes) {
      console.log(`    ID: ${note.id}, Title: ${note.title}, Updated: ${note.updatedAt}, Dismissed: ${JSON.stringify(note)}`)
    }
  }
}

main()
  .catch(e => {
    console.error(e)
    process.exit(1)
  })
  .finally(async () => {
    await prisma.$disconnect()
  })
