fix: bayat dev-mock raporlar tek kapıdan (kullanicininRaporu) ayıklanıyor
All checks were successful
Deploy / deploy (push) Successful in 9m25s
All checks were successful
Deploy / deploy (push) Successful in 9m25s
Dev'de API anahtarı yokken üretilen mock rapor DB'ye kaydediliyordu; anahtar sonradan eklenince kullanıcı başına tek rapor kuralı yüzünden o bayat mock gerçek AI çıktısıymış gibi servis edilmeye devam ediyordu. Rapor tablosunu okuyan her yer (sonuc/listem/yazdir/odeme-sonuc sayfaları, liste action'ları, soru API'si, dev panel) artık src/lib/rapor-kaydi.ts içindeki kullanicininRaporu() kapısından geçiyor: gerçek AI aktifken mock üretimi kayıt "yok" sayılır, kullanıcı gerçek listeyi yeniden üretir. Yeni mock kayıtlar devMock işareti taşır; eskiler metin ön ekinden tanınır. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
krediBittiIsaretle,
|
||||
} from "@/lib/credits";
|
||||
import { anahtarVar, SORUMLULUK_REDDI } from "@/lib/ai/client";
|
||||
import { kullanicininRaporu } from "@/lib/rapor-kaydi";
|
||||
import { sohbetAkisi } from "@/lib/ai/cagri";
|
||||
import { listeOzetiCikar, type RaporSonuc } from "@/lib/ai/rapor";
|
||||
import type { RaporParams } from "@/lib/rapor-havuzu";
|
||||
@@ -122,10 +123,8 @@ export async function POST(request: NextRequest) {
|
||||
return Response.json({ error: "Geçersiz mesaj." }, { status: 400 });
|
||||
}
|
||||
|
||||
// Soru sormak için önce liste oluşturulmuş olmalı
|
||||
const rapor = await appDb.query.reports.findFirst({
|
||||
where: eq(schema.reports.userId, session.user.id),
|
||||
});
|
||||
// Soru sormak için önce liste oluşturulmuş olmalı (bayat dev mock sayılmaz)
|
||||
const rapor = await kullanicininRaporu(session.user.id);
|
||||
if (!rapor?.result) {
|
||||
return Response.json(
|
||||
{ error: "Önce listeni oluşturmalısın.", code: "NO_REPORT" },
|
||||
|
||||
@@ -4,6 +4,7 @@ import { redirect } from "next/navigation";
|
||||
import { MessageCircleQuestion, Sparkles } from "lucide-react";
|
||||
import { verifySession, getCurrentUser } from "@/lib/session";
|
||||
import { appDb, schema } from "@/lib/appdb";
|
||||
import { kullanicininRaporu } from "@/lib/rapor-kaydi";
|
||||
import { URUNLER, MAX_REVIZYON } from "@/lib/credits";
|
||||
import type { RaporSonuc } from "@/lib/ai/rapor";
|
||||
import type { RaporParams } from "@/lib/rapor-havuzu";
|
||||
@@ -44,9 +45,7 @@ export default async function ListemPage({
|
||||
const [user, params, satir, sohbetGecmisi] = await Promise.all([
|
||||
getCurrentUser(),
|
||||
searchParams,
|
||||
appDb.query.reports.findFirst({
|
||||
where: eq(schema.reports.userId, session.user.id),
|
||||
}),
|
||||
kullanicininRaporu(session.user.id),
|
||||
appDb
|
||||
.select({
|
||||
id: schema.chatMessages.id,
|
||||
|
||||
@@ -4,6 +4,7 @@ import { eq } from "drizzle-orm";
|
||||
import { ArrowRight, CheckCircle2, XCircle } from "lucide-react";
|
||||
import { verifySession } from "@/lib/session";
|
||||
import { appDb, schema } from "@/lib/appdb";
|
||||
import { kullanicininRaporu } from "@/lib/rapor-kaydi";
|
||||
import { odemeyiSonuclandir } from "@/lib/odeme";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { PagePixelDivider } from "@/components/pixel-decor";
|
||||
@@ -48,12 +49,7 @@ export default async function OdemeSonucPage({
|
||||
|
||||
// Rapor zaten üretildiyse ödül bir tık uzakta: kullanıcıyı doğrudan
|
||||
// rapor sayfasına döndür ki blur çözülme animasyonuyla tam listeyi görsün.
|
||||
const rapor = basarili
|
||||
? await appDb.query.reports.findFirst({
|
||||
where: eq(schema.reports.userId, session.user.id),
|
||||
columns: { id: true },
|
||||
})
|
||||
: null;
|
||||
const rapor = basarili ? await kullanicininRaporu(session.user.id) : null;
|
||||
const listeHref = rapor ? "/listem?acildi=1" : null;
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import type { Metadata } from "next";
|
||||
import { eq } from "drizzle-orm";
|
||||
import Image from "next/image";
|
||||
import { redirect } from "next/navigation";
|
||||
import { verifySession, getCurrentUser } from "@/lib/session";
|
||||
import { appDb, schema } from "@/lib/appdb";
|
||||
import { kullanicininRaporu } from "@/lib/rapor-kaydi";
|
||||
import { PUAN_TURLERI } from "@/lib/db";
|
||||
import type { RaporSonuc } from "@/lib/ai/rapor";
|
||||
import type { RaporParams } from "@/lib/rapor-havuzu";
|
||||
@@ -25,9 +24,7 @@ export default async function YazdirPage() {
|
||||
// Kullanıcı satırı ile rapor sorgusu bağımsız — paralel çöz
|
||||
const [user, satir] = await Promise.all([
|
||||
getCurrentUser(),
|
||||
appDb.query.reports.findFirst({
|
||||
where: eq(schema.reports.userId, session.user.id),
|
||||
}),
|
||||
kullanicininRaporu(session.user.id),
|
||||
]);
|
||||
if (!user) redirect("/giris");
|
||||
if (!user.hasPaket) redirect("/paket");
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { and, eq, sql } from "drizzle-orm";
|
||||
import { getSession, getCurrentUser } from "@/lib/session";
|
||||
import { appDb, schema } from "@/lib/appdb";
|
||||
import { kullanicininRaporu } from "@/lib/rapor-kaydi";
|
||||
import { PUAN_TURLERI, type PuanTuruKey } from "@/lib/db";
|
||||
import {
|
||||
spendCredits,
|
||||
@@ -145,9 +146,7 @@ export async function listeOlustur(input: {
|
||||
"Önceki denemen başarısız olduğu için kredin iade edilmişti. Tekrar dener misin?",
|
||||
};
|
||||
}
|
||||
const mevcut = await appDb.query.reports.findFirst({
|
||||
where: eq(schema.reports.userId, user.id),
|
||||
});
|
||||
const mevcut = await kullanicininRaporu(user.id);
|
||||
if (mevcut?.result) {
|
||||
const rapor = mevcut.result as RaporSonuc;
|
||||
return {
|
||||
@@ -225,9 +224,7 @@ export async function listeRevize(input: {
|
||||
return { ok: false, code: "HATA", error: "Geçersiz istek." };
|
||||
}
|
||||
|
||||
const rapor = await appDb.query.reports.findFirst({
|
||||
where: eq(schema.reports.userId, user.id),
|
||||
});
|
||||
const rapor = await kullanicininRaporu(user.id);
|
||||
if (!rapor?.result) {
|
||||
return { ok: false, code: "HATA", error: "Önce bir liste oluşturmalısın." };
|
||||
}
|
||||
@@ -274,9 +271,7 @@ export async function listeRevize(input: {
|
||||
"Önceki denemen başarısız olduğu için kredin iade edilmişti. Tekrar dener misin?",
|
||||
};
|
||||
}
|
||||
const guncel = await appDb.query.reports.findFirst({
|
||||
where: eq(schema.reports.userId, user.id),
|
||||
});
|
||||
const guncel = await kullanicininRaporu(user.id);
|
||||
if (guncel?.result) {
|
||||
return {
|
||||
ok: true,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { Metadata } from "next";
|
||||
import { eq } from "drizzle-orm";
|
||||
import {
|
||||
PUAN_TURLERI,
|
||||
rankWindowFacets,
|
||||
@@ -7,7 +6,7 @@ import {
|
||||
type PuanTuruKey,
|
||||
} from "@/lib/db";
|
||||
import { getSession } from "@/lib/session";
|
||||
import { appDb, schema } from "@/lib/appdb";
|
||||
import { kullanicininRaporu } from "@/lib/rapor-kaydi";
|
||||
import { tadimlikSec } from "@/lib/tadimlik-havuzu";
|
||||
import { SihirbazBolumu } from "./sihirbaz-cagri-karti";
|
||||
import { TadimlikSatiri } from "./tadimlik-satiri";
|
||||
@@ -55,10 +54,7 @@ export default async function SonucPage({
|
||||
// için varlık bilgisi gerekir.
|
||||
const session = await getSession();
|
||||
const raporSatiri = session
|
||||
? await appDb.query.reports.findFirst({
|
||||
where: eq(schema.reports.userId, session.user.id),
|
||||
columns: { result: true },
|
||||
})
|
||||
? await kullanicininRaporu(session.user.id)
|
||||
: null;
|
||||
|
||||
const facetler = rankWindowFacets(sira, turKey);
|
||||
|
||||
Reference in New Issue
Block a user