fix: delete annotations and participants before experiment, skip calibration when disabled, remove Startseite link from annotation view
This commit is contained in:
@@ -113,7 +113,6 @@ function calculateDialectScores(
|
|||||||
* Returns true if calibration is completed or not required, false if calibration is pending.
|
* Returns true if calibration is completed or not required, false if calibration is pending.
|
||||||
*/
|
*/
|
||||||
export async function isCalibrationDone(experimentId: number): Promise<boolean> {
|
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() });
|
const session = await auth.api.getSession({ headers: await headers() });
|
||||||
if (!session) throw new Error('Nicht angemeldet');
|
if (!session) throw new Error('Nicht angemeldet');
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { experiment_calibration } from '@/lib/model/experiment_calibration';
|
|||||||
import { annotation } from '@/lib/model/annotation';
|
import { annotation } from '@/lib/model/annotation';
|
||||||
import { participant } from '@/lib/model/participant';
|
import { participant } from '@/lib/model/participant';
|
||||||
import { dataset_entry } from '@/lib/model/dataset_entry';
|
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 { revalidatePath } from 'next/cache';
|
||||||
import { auth, requireAdmin } from '@/lib/auth';
|
import { auth, requireAdmin } from '@/lib/auth';
|
||||||
import { isParticipantCalibrationDone } from './calibration-scoring';
|
import { isParticipantCalibrationDone } from './calibration-scoring';
|
||||||
@@ -111,7 +111,9 @@ export async function deleteExperiment(id: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
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));
|
await db.delete(experiment_calibration).where(eq(experiment_calibration.experimentId, id));
|
||||||
|
|
||||||
// Delete the experiment
|
// Delete the experiment
|
||||||
|
|||||||
@@ -189,9 +189,6 @@ export default function AnnotationPageView({
|
|||||||
<div className="flex-1 flex items-center justify-center">
|
<div className="flex-1 flex items-center justify-center">
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<p className="text-gray-600">Unbekannter Annotation-Typ: {viewType}</p>
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -274,12 +271,7 @@ export default function AnnotationPageView({
|
|||||||
>
|
>
|
||||||
{sidebarOpen ? '✕' : '☰'}
|
{sidebarOpen ? '✕' : '☰'}
|
||||||
</button>
|
</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 && (
|
{Object.keys(dialectScores).length > 0 && (
|
||||||
<button
|
<button
|
||||||
onClick={() => setIsCalibrationModalOpen(true)}
|
onClick={() => setIsCalibrationModalOpen(true)}
|
||||||
|
|||||||
Reference in New Issue
Block a user