import { PrismaClient } from '@prisma/client';
import * as dotenv from 'dotenv';

dotenv.config();

const prisma = new PrismaClient();

// BigInt serialization fix
(BigInt.prototype as any).toJSON = function () {
  return this.toString();
};

async function getMatch() {
  try {
    const match = await prisma.liveMatch.findUnique({
      where: { id: '3kemwubzpmga0nwhtc0o0vgno' },
      include: {
        homeTeam: true,
        awayTeam: true,
        league: true,
      },
    });

    if (!match) {
      console.log('❌ Maç bulunamadı!');
      return;
    }

    console.log('✅ Maç bulundu:');
    console.log(JSON.stringify(match, null, 2));

    // Maç bilgilerini özetle
    console.log('\n📊 MAÇ ÖZETİ:');
    console.log('ID:', match.id);
    console.log('Slug:', match.matchSlug);
    console.log('Ev sahibi:', match.homeTeam?.name);
    console.log('Deplasman:', match.awayTeam?.name);
    console.log('Lig:', match.league?.name);
    console.log('Durum:', match.status);
    console.log('Spor:', match.sport);
    console.log('Maç Zamanı (MS):', match.mstUtc?.toString());
    console.log('Skor:', match.scoreHome, '-', match.scoreAway);

  } catch (error) {
    console.error('❌ Hata:', error);
  } finally {
    await prisma.$disconnect();
  }
}

getMatch();
