From ab2c1f72204f7a4e66e30bbe430d24bba02a0ac4 Mon Sep 17 00:00:00 2001 From: smaubio <118258478+smaubio@users.noreply.github.com> Date: Fri, 10 Apr 2026 07:54:21 +0200 Subject: [PATCH] fix: delete annotations and participants before experiment, skip calibration when disabled, remove Startseite link from annotation view --- src/app/actions/calibration-scoring.ts | 5 ++--- src/app/actions/experiment.ts | 8 +++++--- src/components/AnnotationViews/AnnotationPageView.tsx | 10 +--------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/app/actions/calibration-scoring.ts b/src/app/actions/calibration-scoring.ts index 3e38f30..eee386d 100644 --- a/src/app/actions/calibration-scoring.ts +++ b/src/app/actions/calibration-scoring.ts @@ -113,7 +113,6 @@ function calculateDialectScores( * Returns true if calibration is completed or not required, false if calibration is pending. */ export async function isCalibrationDone(experimentId: number): Promise { - console.log('Checking calibration status for experimentId:', experimentId); const session = await auth.api.getSession({ headers: await headers() }); if (!session) throw new Error('Nicht angemeldet'); @@ -123,11 +122,11 @@ export async function isCalibrationDone(experimentId: number): Promise .from(experiment) .where(eq(experiment.id, experimentId)) .limit(1); - + if (exp.length === 0) { throw new Error('Experiment not found'); } - + // If calibration is not enabled, consider it done if (!exp[0].calibrationEnabled) { return true; diff --git a/src/app/actions/experiment.ts b/src/app/actions/experiment.ts index f9fc64e..9673f80 100644 --- a/src/app/actions/experiment.ts +++ b/src/app/actions/experiment.ts @@ -6,7 +6,7 @@ import { experiment_calibration } from '@/lib/model/experiment_calibration'; import { annotation } from '@/lib/model/annotation'; import { participant } from '@/lib/model/participant'; import { dataset_entry } from '@/lib/model/dataset_entry'; -import { and, eq, count, sql, isNotNull } from 'drizzle-orm'; +import { and, eq, count, sql } from 'drizzle-orm'; import { revalidatePath } from 'next/cache'; import { auth, requireAdmin } from '@/lib/auth'; import { isParticipantCalibrationDone } from './calibration-scoring'; @@ -111,9 +111,11 @@ export async function deleteExperiment(id: number) { } try { - // Delete all experiment_calibration records first + // Delete all child records first (FK constraints) + await db.delete(annotation).where(eq(annotation.experimentId, id)); + await db.delete(participant).where(eq(participant.experimentId, id)); await db.delete(experiment_calibration).where(eq(experiment_calibration.experimentId, id)); - + // Delete the experiment await db.delete(experiment).where(eq(experiment.id, id)); diff --git a/src/components/AnnotationViews/AnnotationPageView.tsx b/src/components/AnnotationViews/AnnotationPageView.tsx index a80a369..7c95428 100644 --- a/src/components/AnnotationViews/AnnotationPageView.tsx +++ b/src/components/AnnotationViews/AnnotationPageView.tsx @@ -189,9 +189,6 @@ export default function AnnotationPageView({

Unbekannter Annotation-Typ: {viewType}

- - ← Startseite -
@@ -274,12 +271,7 @@ export default function AnnotationPageView({ > {sidebarOpen ? '✕' : '☰'} - - ← Startseite - + {Object.keys(dialectScores).length > 0 && (