import { prisma } from "@streamclipper/db"; export const dynamic = "force-dynamic"; const STT_COST_PER_MINUTE = 0.006; // OpenAI Whisper API, doğrulanmalı — bkz. openai.com/pricing const GB_PER_HOUR_ESTIMATE = 1.3; // 2026-09-02 oturumunda ölçülen ~2.8 Mbps ortalama bitrate'ten function fmt(n: number, digits = 1): string { return n.toLocaleString("tr-TR", { minimumFractionDigits: digits, maximumFractionDigits: digits }); } export default async function StatsPage() { const [transcribed, durationSum, readyShorts, failedShorts, totalCandidates] = await Promise.all([ prisma.candidateSegment.findMany({ where: { status: "TRANSCRIBED" }, select: { startSec: true, endSec: true }, }), prisma.rawSegment.aggregate({ _sum: { duration: true } }), prisma.shortVideo.count({ where: { status: "READY" } }), prisma.shortVideo.count({ where: { status: "FAILED" } }), prisma.candidateSegment.count(), ]); const sttSeconds = transcribed.reduce((sum, c) => sum + Math.max(0, c.endSec - c.startSec), 0); const sttMinutes = sttSeconds / 60; const sttCost = sttMinutes * STT_COST_PER_MINUTE; const captureSeconds = durationSum._sum.duration ?? 0; const captureHours = captureSeconds / 3600; const estimatedGb = captureHours * GB_PER_HOUR_ESTIMATE; return ( <>
Şimdiye kadarki toplam kullanım — tüm zamanlar. STT maliyeti ve disk kullanımı tahmini (bkz. maliyet analizi), gerçek faturayla küçük farklar olabilir.