Refactor annotation tools and implement quality choice annotation feature

- Updated the annotation label from "bewertet" to "annotiert" in the HomePage component.
- Removed the SingleChoiceView component and replaced it with a new QualityChoiceEntryView component for handling quality choice annotations.
- Introduced QualityChoiceView component to manage the flow of quality choice annotations, including navigation and progress tracking.
- Updated EditableExperimentHeader to default to 'quality-choice' annotation tool.
- Added unique index for annotations in the database schema to prevent duplicate entries.
- Enhanced WaveformPlayer to support audio playback state management.
This commit is contained in:
averel10
2026-03-20 10:01:20 +01:00
parent ea7c75c523
commit f26a0a7906
12 changed files with 1070 additions and 224 deletions

View File

@@ -66,7 +66,7 @@ export async function getAnnotationEntries(experimentId: number): Promise<Datase
/**
* Persists a batch of ratings for the authenticated user.
* Silently ignores duplicates (onConflictDoNothing).
* Updates existing annotations with the same userId, experimentId, and datasetEntryId.
*/
export async function saveAnnotations(
ratings: { entryId: number; rating: number; dialectLabel: string }[],
@@ -81,7 +81,13 @@ export async function saveAnnotations(
await db
.insert(annotation)
.values({experimentId, datasetEntryId: entryId, userId: session.user.id, rating, dialectLabel })
.onConflictDoNothing();
.onConflictDoUpdate({
target: [annotation.userId, annotation.experimentId, annotation.datasetEntryId],
set: {
rating,
dialectLabel,
}
});
}
}