fix: delete annotations and participants before experiment, skip calibration when disabled, remove Startseite link from annotation view

This commit is contained in:
smaubio
2026-04-10 07:54:21 +02:00
parent 12c3ffc556
commit ab2c1f7220
3 changed files with 8 additions and 15 deletions

View File

@@ -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<boolean> {
console.log('Checking calibration status for experimentId:', experimentId);
const session = await auth.api.getSession({ headers: await headers() });
if (!session) throw new Error('Nicht angemeldet');

View File

@@ -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,7 +111,9 @@ 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

View File

@@ -189,9 +189,6 @@ export default function AnnotationPageView({
<div className="flex-1 flex items-center justify-center">
<div className="text-center">
<p className="text-gray-600">Unbekannter Annotation-Typ: {viewType}</p>
<Link href="/" className="text-blue-600 hover:underline mt-4 inline-block">
Startseite
</Link>
</div>
</div>
</div>
@@ -274,12 +271,7 @@ export default function AnnotationPageView({
>
{sidebarOpen ? '✕' : '☰'}
</button>
<Link
href="/"
className="text-sm px-3 py-1.5 bg-gray-100 hover:bg-gray-200 text-gray-700 rounded-md transition-colors"
>
Startseite
</Link>
{Object.keys(dialectScores).length > 0 && (
<button
onClick={() => setIsCalibrationModalOpen(true)}