added experiment-table: refactored all frontend pages and services

This commit is contained in:
averel10
2026-03-20 06:51:49 +01:00
parent 5464eae0e9
commit 4b35e2392e
13 changed files with 1598 additions and 51 deletions

View File

@@ -0,0 +1,10 @@
CREATE TABLE `experiment` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`dataset_id` integer NOT NULL,
`created_at` integer DEFAULT (unixepoch()) NOT NULL,
`updated_at` integer DEFAULT (unixepoch()) NOT NULL,
FOREIGN KEY (`dataset_id`) REFERENCES `dataset`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
ALTER TABLE `annotation` ADD `experiment_id` integer NOT NULL REFERENCES experiment(id);--> statement-breakpoint
ALTER TABLE `annotation` ADD `updated_at` integer DEFAULT (unixepoch()) NOT NULL;

View File

@@ -0,0 +1,2 @@
ALTER TABLE `experiment` ADD `name` text NOT NULL;--> statement-breakpoint
ALTER TABLE `experiment` ADD `description` text;

View File

@@ -0,0 +1,719 @@
{
"version": "6",
"dialect": "sqlite",
"id": "a3364cec-3ada-496b-8fcb-f339074b04d7",
"prevId": "071a0744-4d6e-4657-948b-7eda495b9756",
"tables": {
"annotation": {
"name": "annotation",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"dataset_entry_id": {
"name": "dataset_entry_id",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"experiment_id": {
"name": "experiment_id",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"rating": {
"name": "rating",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"dialect_label": {
"name": "dialect_label",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(unixepoch())"
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(unixepoch())"
}
},
"indexes": {},
"foreignKeys": {
"annotation_dataset_entry_id_dataset_entry_id_fk": {
"name": "annotation_dataset_entry_id_dataset_entry_id_fk",
"tableFrom": "annotation",
"tableTo": "dataset_entry",
"columnsFrom": [
"dataset_entry_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"annotation_experiment_id_experiment_id_fk": {
"name": "annotation_experiment_id_experiment_id_fk",
"tableFrom": "annotation",
"tableTo": "experiment",
"columnsFrom": [
"experiment_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"account": {
"name": "account",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"account_id": {
"name": "account_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"provider_id": {
"name": "provider_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"access_token": {
"name": "access_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"refresh_token": {
"name": "refresh_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"id_token": {
"name": "id_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"access_token_expires_at": {
"name": "access_token_expires_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"refresh_token_expires_at": {
"name": "refresh_token_expires_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"scope": {
"name": "scope",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"password": {
"name": "password",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(cast(unixepoch('subsecond') * 1000 as integer))"
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"account_userId_idx": {
"name": "account_userId_idx",
"columns": [
"user_id"
],
"isUnique": false
}
},
"foreignKeys": {
"account_user_id_user_id_fk": {
"name": "account_user_id_user_id_fk",
"tableFrom": "account",
"tableTo": "user",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"session": {
"name": "session",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"expires_at": {
"name": "expires_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"token": {
"name": "token",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(cast(unixepoch('subsecond') * 1000 as integer))"
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"ip_address": {
"name": "ip_address",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"user_agent": {
"name": "user_agent",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"session_token_unique": {
"name": "session_token_unique",
"columns": [
"token"
],
"isUnique": true
},
"session_userId_idx": {
"name": "session_userId_idx",
"columns": [
"user_id"
],
"isUnique": false
}
},
"foreignKeys": {
"session_user_id_user_id_fk": {
"name": "session_user_id_user_id_fk",
"tableFrom": "session",
"tableTo": "user",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"user": {
"name": "user",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"email_verified": {
"name": "email_verified",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": false
},
"image": {
"name": "image",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"admin": {
"name": "admin",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(cast(unixepoch('subsecond') * 1000 as integer))"
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(cast(unixepoch('subsecond') * 1000 as integer))"
}
},
"indexes": {
"user_email_unique": {
"name": "user_email_unique",
"columns": [
"email"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"verification": {
"name": "verification",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"identifier": {
"name": "identifier",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"value": {
"name": "value",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires_at": {
"name": "expires_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(cast(unixepoch('subsecond') * 1000 as integer))"
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(cast(unixepoch('subsecond') * 1000 as integer))"
}
},
"indexes": {
"verification_identifier_idx": {
"name": "verification_identifier_idx",
"columns": [
"identifier"
],
"isUnique": false
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"dataset_entry": {
"name": "dataset_entry",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"external_id": {
"name": "external_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"speaker_id": {
"name": "speaker_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"model_name": {
"name": "model_name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"utterance_id": {
"name": "utterance_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"utterance_text": {
"name": "utterance_text",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"dataset_id": {
"name": "dataset_id",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"file_name": {
"name": "file_name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"dialect": {
"name": "dialect",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"iteration": {
"name": "iteration",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"duration_ms": {
"name": "duration_ms",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"rms_value": {
"name": "rms_value",
"type": "real",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"longest_pause": {
"name": "longest_pause",
"type": "real",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"utmos_score": {
"name": "utmos_score",
"type": "real",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"wer_score": {
"name": "wer_score",
"type": "real",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(unixepoch())"
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(unixepoch())"
}
},
"indexes": {},
"foreignKeys": {
"dataset_entry_dataset_id_dataset_id_fk": {
"name": "dataset_entry_dataset_id_dataset_id_fk",
"tableFrom": "dataset_entry",
"tableTo": "dataset",
"columnsFrom": [
"dataset_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"dataset": {
"name": "dataset",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(unixepoch())"
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(unixepoch())"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"experiment": {
"name": "experiment",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"dataset_id": {
"name": "dataset_id",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(unixepoch())"
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(unixepoch())"
}
},
"indexes": {},
"foreignKeys": {
"experiment_dataset_id_dataset_id_fk": {
"name": "experiment_dataset_id_dataset_id_fk",
"tableFrom": "experiment",
"tableTo": "dataset",
"columnsFrom": [
"dataset_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
}
},
"views": {},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}

View File

@@ -0,0 +1,733 @@
{
"version": "6",
"dialect": "sqlite",
"id": "4773999c-10cb-4a54-b2e8-aec0988f7a7b",
"prevId": "a3364cec-3ada-496b-8fcb-f339074b04d7",
"tables": {
"annotation": {
"name": "annotation",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"dataset_entry_id": {
"name": "dataset_entry_id",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"experiment_id": {
"name": "experiment_id",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"rating": {
"name": "rating",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"dialect_label": {
"name": "dialect_label",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(unixepoch())"
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(unixepoch())"
}
},
"indexes": {},
"foreignKeys": {
"annotation_dataset_entry_id_dataset_entry_id_fk": {
"name": "annotation_dataset_entry_id_dataset_entry_id_fk",
"tableFrom": "annotation",
"tableTo": "dataset_entry",
"columnsFrom": [
"dataset_entry_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"annotation_experiment_id_experiment_id_fk": {
"name": "annotation_experiment_id_experiment_id_fk",
"tableFrom": "annotation",
"tableTo": "experiment",
"columnsFrom": [
"experiment_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"account": {
"name": "account",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"account_id": {
"name": "account_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"provider_id": {
"name": "provider_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"access_token": {
"name": "access_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"refresh_token": {
"name": "refresh_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"id_token": {
"name": "id_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"access_token_expires_at": {
"name": "access_token_expires_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"refresh_token_expires_at": {
"name": "refresh_token_expires_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"scope": {
"name": "scope",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"password": {
"name": "password",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(cast(unixepoch('subsecond') * 1000 as integer))"
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"account_userId_idx": {
"name": "account_userId_idx",
"columns": [
"user_id"
],
"isUnique": false
}
},
"foreignKeys": {
"account_user_id_user_id_fk": {
"name": "account_user_id_user_id_fk",
"tableFrom": "account",
"tableTo": "user",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"session": {
"name": "session",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"expires_at": {
"name": "expires_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"token": {
"name": "token",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(cast(unixepoch('subsecond') * 1000 as integer))"
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"ip_address": {
"name": "ip_address",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"user_agent": {
"name": "user_agent",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"session_token_unique": {
"name": "session_token_unique",
"columns": [
"token"
],
"isUnique": true
},
"session_userId_idx": {
"name": "session_userId_idx",
"columns": [
"user_id"
],
"isUnique": false
}
},
"foreignKeys": {
"session_user_id_user_id_fk": {
"name": "session_user_id_user_id_fk",
"tableFrom": "session",
"tableTo": "user",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"user": {
"name": "user",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"email_verified": {
"name": "email_verified",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": false
},
"image": {
"name": "image",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"admin": {
"name": "admin",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(cast(unixepoch('subsecond') * 1000 as integer))"
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(cast(unixepoch('subsecond') * 1000 as integer))"
}
},
"indexes": {
"user_email_unique": {
"name": "user_email_unique",
"columns": [
"email"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"verification": {
"name": "verification",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"identifier": {
"name": "identifier",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"value": {
"name": "value",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires_at": {
"name": "expires_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(cast(unixepoch('subsecond') * 1000 as integer))"
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(cast(unixepoch('subsecond') * 1000 as integer))"
}
},
"indexes": {
"verification_identifier_idx": {
"name": "verification_identifier_idx",
"columns": [
"identifier"
],
"isUnique": false
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"dataset_entry": {
"name": "dataset_entry",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"external_id": {
"name": "external_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"speaker_id": {
"name": "speaker_id",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"model_name": {
"name": "model_name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"utterance_id": {
"name": "utterance_id",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"utterance_text": {
"name": "utterance_text",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"dataset_id": {
"name": "dataset_id",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"file_name": {
"name": "file_name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"dialect": {
"name": "dialect",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"iteration": {
"name": "iteration",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"duration_ms": {
"name": "duration_ms",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"rms_value": {
"name": "rms_value",
"type": "real",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"longest_pause": {
"name": "longest_pause",
"type": "real",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"utmos_score": {
"name": "utmos_score",
"type": "real",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"wer_score": {
"name": "wer_score",
"type": "real",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(unixepoch())"
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(unixepoch())"
}
},
"indexes": {},
"foreignKeys": {
"dataset_entry_dataset_id_dataset_id_fk": {
"name": "dataset_entry_dataset_id_dataset_id_fk",
"tableFrom": "dataset_entry",
"tableTo": "dataset",
"columnsFrom": [
"dataset_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"dataset": {
"name": "dataset",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(unixepoch())"
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(unixepoch())"
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"experiment": {
"name": "experiment",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"dataset_id": {
"name": "dataset_id",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(unixepoch())"
},
"updated_at": {
"name": "updated_at",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "(unixepoch())"
}
},
"indexes": {},
"foreignKeys": {
"experiment_dataset_id_dataset_id_fk": {
"name": "experiment_dataset_id_dataset_id_fk",
"tableFrom": "experiment",
"tableTo": "dataset",
"columnsFrom": [
"dataset_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
}
},
"views": {},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}

View File

@@ -57,6 +57,20 @@
"when": 1773410584481, "when": 1773410584481,
"tag": "0007_light_spiral", "tag": "0007_light_spiral",
"breakpoints": true "breakpoints": true
},
{
"idx": 8,
"version": "6",
"when": 1773984793043,
"tag": "0008_dark_gauntlet",
"breakpoints": true
},
{
"idx": 9,
"version": "6",
"when": 1773985687853,
"tag": "0009_mysterious_brother_voodoo",
"breakpoints": true
} }
] ]
} }

View File

@@ -7,44 +7,58 @@ import { annotation } from '@/lib/model/annotation';
import { eq, and } from 'drizzle-orm'; import { eq, and } from 'drizzle-orm';
import { auth } from '@/lib/auth'; import { auth } from '@/lib/auth';
import { headers } from 'next/headers'; import { headers } from 'next/headers';
import type { AnnotationEntry } from '@/lib/dialects'; import type { DatasetEntryForAnnotation } from '@/lib/dialects';
import { experiment } from '@/lib/model/experiment';
/** /**
* Returns unannotated entries for the given dataset and authenticated user. * Returns unannotated entries for the given dataset and authenticated user.
*/ */
export async function getAnnotationEntries(datasetId: number): Promise<AnnotationEntry[]> { export async function getAnnotationEntries(experimentId: number): Promise<DatasetEntryForAnnotation[]> {
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');
const allEntries = await db const currentExperiments = await db
.select()
.from(experiment)
.where(eq(experiment.id, experimentId))
.leftJoin(dataset, eq(experiment.datasetId, dataset.id))
.limit(1);
if (currentExperiments.length === 0) {
throw new Error('Experiment nicht gefunden');
}
if(!currentExperiments[0].dataset) {
throw new Error('Experiment hat kein zugeordnetes Dataset');
}
const allDatasetEntries = await db
.select() .select()
.from(dataset_entry) .from(dataset_entry)
.where(eq(dataset_entry.datasetId, datasetId)); .where(eq(dataset_entry.datasetId, currentExperiments[0].dataset.id));
if (allEntries.length === 0) return []; if (allDatasetEntries.length === 0) return [];
// Find entries already annotated by this user in this dataset (via join) // Find entries already annotated by this user in this dataset (via join)
const annotated = await db const annotationEntries = await db
.select({ entryId: annotation.datasetEntryId }) .select()
.from(annotation) .from(annotation)
.innerJoin(dataset_entry, eq(annotation.datasetEntryId, dataset_entry.id))
.where( .where(
and( and(
eq(annotation.userId, session.user.id), eq(annotation.userId, session.user.id),
eq(dataset_entry.datasetId, datasetId) eq(annotation.experimentId, experimentId)
) )
); );
const annotatedIds = new Set(annotated.map((a) => a.entryId)); const mapped: DatasetEntryForAnnotation[] = allDatasetEntries.map((e) => ({
const remaining = allEntries.filter((e) => !annotatedIds.has(e.id));
const mapped: AnnotationEntry[] = remaining.map((e) => ({
id: e.id, id: e.id,
externalId: e.externalId, externalId: e.externalId,
fileName: e.fileName, fileName: e.fileName,
dialect: e.dialect, dialect: e.dialect,
durationMs: e.durationMs, durationMs: e.durationMs,
experimentId: experimentId,
datasetId: e.datasetId, datasetId: e.datasetId,
annotation: annotationEntries.find((a) => a.datasetEntryId === e.id)?.rating || null,
})); }));
return mapped; return mapped;
@@ -55,7 +69,8 @@ export async function getAnnotationEntries(datasetId: number): Promise<Annotatio
* Silently ignores duplicates (onConflictDoNothing). * Silently ignores duplicates (onConflictDoNothing).
*/ */
export async function saveAnnotations( export async function saveAnnotations(
ratings: { entryId: number; rating: number; dialectLabel: string }[] ratings: { entryId: number; rating: number; dialectLabel: string }[],
experimentId: number
): Promise<void> { ): Promise<void> {
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');
@@ -65,22 +80,30 @@ export async function saveAnnotations(
for (const { entryId, rating, dialectLabel } of ratings) { for (const { entryId, rating, dialectLabel } of ratings) {
await db await db
.insert(annotation) .insert(annotation)
.values({ datasetEntryId: entryId, userId: session.user.id, rating, dialectLabel }) .values({experimentId, datasetEntryId: entryId, userId: session.user.id, rating, dialectLabel })
.onConflictDoNothing(); .onConflictDoNothing();
} }
} }
/** Returns all datasets (for the home page). */ /** Returns all datasets (for the home page). */
export async function getAllDatasets() { export async function getAllExperiments() {
return db.select().from(dataset).orderBy(dataset.name); return db.select().from(experiment).orderBy(experiment.id);
} }
/** Returns annotation progress for the current user in a dataset. */ /** Returns annotation progress for the current user in a dataset. */
export async function getAnnotationProgress( export async function getAnnotationProgress(
datasetId: number experimentId: number
): Promise<{ total: number; done: number }> { ): Promise<{ total: number; done: number }> {
const session = await auth.api.getSession({ headers: await headers() }); const session = await auth.api.getSession({ headers: await headers() });
const datasetIdResult = await db
.select({ datasetId: experiment.datasetId })
.from(experiment)
.where(eq(experiment.id, experimentId))
.limit(1);
const datasetId = datasetIdResult[0]?.datasetId;
const allEntries = await db const allEntries = await db
.select({ id: dataset_entry.id }) .select({ id: dataset_entry.id })
.from(dataset_entry) .from(dataset_entry)
@@ -97,7 +120,7 @@ export async function getAnnotationProgress(
.where( .where(
and( and(
eq(annotation.userId, session.user.id), eq(annotation.userId, session.user.id),
eq(dataset_entry.datasetId, datasetId) eq(annotation.experimentId, experimentId)
) )
); );

View File

View File

@@ -6,20 +6,20 @@ import { getAnnotationEntries } from '@/app/actions/annotations';
import SingleChoiceView from '@/components/AnnotationViews/SingleChoiceView'; import SingleChoiceView from '@/components/AnnotationViews/SingleChoiceView';
interface Props { interface Props {
params: Promise<{ datasetId: string; prototype: string }>; params: Promise<{ experimentId: string; prototype: string }>;
} }
export default async function AnnotatePage({ params }: Props) { export default async function AnnotatePage({ params }: Props) {
const session = await auth.api.getSession({ headers: await headers() }); const session = await auth.api.getSession({ headers: await headers() });
if (!session) redirect('/user/sign-in'); if (!session) redirect('/user/sign-in');
const { datasetId: datasetIdStr, prototype } = await params; const { experimentId: experimentIdStr, prototype } = await params;
const datasetId = parseInt(datasetIdStr, 10); const experimentId = parseInt(experimentIdStr, 10);
if (isNaN(datasetId)) { if (isNaN(experimentId)) {
return ( return (
<div className="max-w-xl mx-auto py-16 text-center"> <div className="max-w-xl mx-auto py-16 text-center">
<p className="text-gray-600">Ungültige Dataset-ID.</p> <p className="text-gray-600">Ungültige Experiment-ID.</p>
<Link href="/" className="text-blue-600 hover:underline mt-4 inline-block"> <Link href="/" className="text-blue-600 hover:underline mt-4 inline-block">
Startseite Startseite
</Link> </Link>
@@ -31,7 +31,7 @@ export default async function AnnotatePage({ params }: Props) {
notFound(); notFound();
} }
const entries = await getAnnotationEntries(datasetId); const entries = await getAnnotationEntries(experimentId);
if (entries.length === 0) { if (entries.length === 0) {
return ( return (
@@ -41,7 +41,7 @@ export default async function AnnotatePage({ params }: Props) {
Alle Samples bewertet! Alle Samples bewertet!
</h1> </h1>
<p className="text-gray-600 mb-8"> <p className="text-gray-600 mb-8">
Sie haben alle Samples in diesem Dataset bereits bewertet. Danke für Ihre Mitarbeit! Sie haben alle Samples in diesem Experiment bereits bewertet. Danke für Ihre Mitarbeit!
</p> </p>
<Link <Link
href="/" href="/"
@@ -53,5 +53,5 @@ export default async function AnnotatePage({ params }: Props) {
); );
} }
return <SingleChoiceView entries={entries} datasetId={datasetId} />; return <SingleChoiceView entries={entries} experimentId={experimentId} />;
} }

View File

@@ -1,7 +1,7 @@
import Link from 'next/link'; import Link from 'next/link';
import { headers } from 'next/headers'; import { headers } from 'next/headers';
import { auth } from '@/lib/auth'; import { auth } from '@/lib/auth';
import { getAllDatasets, getAnnotationProgress } from '@/app/actions/annotations'; import { getAllExperiments, getAnnotationProgress } from '@/app/actions/annotations';
export default async function HomePage() { export default async function HomePage() {
const session = await auth.api.getSession({ headers: await headers() }); const session = await auth.api.getSession({ headers: await headers() });
@@ -25,49 +25,49 @@ export default async function HomePage() {
); );
} }
const datasets = await getAllDatasets(); const experiments = await getAllExperiments();
if (datasets.length === 0) { if (experiments.length === 0) {
return ( return (
<div className="max-w-xl mx-auto text-center py-20"> <div className="max-w-xl mx-auto text-center py-20">
<h1 className="text-2xl font-bold text-gray-800 mb-3"> <h1 className="text-2xl font-bold text-gray-800 mb-3">
Keine Datasets verfügbar Keine Experimente verfügbar
</h1> </h1>
<p className="text-gray-500"> <p className="text-gray-500">
Es wurden noch keine Datasets angelegt. Wenden Sie sich an einen Administrator. Es wurden noch keine Experimente freigeschalten. Wenden Sie sich an einen Administrator.
</p> </p>
</div> </div>
); );
} }
// Fetch progress for all datasets in parallel // Fetch progress for all experiments in parallel
const progressData = await Promise.all( const progressData = await Promise.all(
datasets.map((ds) => getAnnotationProgress(ds.id)) experiments.map((exp) => getAnnotationProgress(exp.id))
); );
return ( return (
<div className="max-w-2xl mx-auto py-8"> <div className="max-w-2xl mx-auto py-8">
<h1 className="text-2xl font-bold text-gray-800 mb-2">Datasets</h1> <h1 className="text-2xl font-bold text-gray-800 mb-2">Experimente</h1>
<p className="text-gray-500 mb-8"> <p className="text-gray-500 mb-8">
Wählen Sie ein Dataset aus, um mit der Annotation zu beginnen oder fortzufahren. Wählen Sie ein Experiment aus, um mit der Annotation zu beginnen oder fortzufahren.
</p> </p>
<div className="flex flex-col gap-4"> <div className="flex flex-col gap-4">
{datasets.map((ds, i) => { {experiments.map((exp, i) => {
const { total, done } = progressData[i]; const { total, done } = progressData[i];
const pct = total > 0 ? Math.round((done / total) * 100) : 0; const pct = total > 0 ? Math.round((done / total) * 100) : 0;
const isFinished = total > 0 && done >= total; const isFinished = total > 0 && done >= total;
return ( return (
<div <div
key={ds.id} key={exp.id}
className="bg-white border border-gray-200 rounded-xl p-5 shadow-sm" className="bg-white border border-gray-200 rounded-xl p-5 shadow-sm"
> >
<div className="flex items-start justify-between gap-4"> <div className="flex items-start justify-between gap-4">
<div className="flex-1 min-w-0"> <div className="flex-1 min-w-0">
<h2 className="font-semibold text-gray-800 truncate">{ds.name}</h2> <h2 className="font-semibold text-gray-800 truncate">{exp.name}</h2>
{ds.description && ( {exp.description && (
<p className="text-sm text-gray-500 mt-0.5">{ds.description}</p> <p className="text-sm text-gray-500 mt-0.5">{exp.description}</p>
)} )}
{/* Progress */} {/* Progress */}
@@ -88,7 +88,7 @@ export default async function HomePage() {
</div> </div>
<Link <Link
href={`/annotate/${ds.id}`} href={`/annotate/${exp.id}`}
className={`flex-shrink-0 px-4 py-2 rounded-lg font-medium text-sm transition-colors ${ className={`flex-shrink-0 px-4 py-2 rounded-lg font-medium text-sm transition-colors ${
isFinished isFinished
? 'bg-green-100 text-green-700 hover:bg-green-200' ? 'bg-green-100 text-green-700 hover:bg-green-200'

View File

@@ -4,7 +4,7 @@ import { useState, useEffect, useTransition } from 'react';
import Link from 'next/link'; import Link from 'next/link';
import WaveformPlayer from '../WaveformPlayer'; import WaveformPlayer from '../WaveformPlayer';
import { saveAnnotations } from '@/app/actions/annotations'; import { saveAnnotations } from '@/app/actions/annotations';
import { type AnnotationEntry, DIALECT_LABELS } from '@/lib/dialects'; import { type DatasetEntryForAnnotation, DIALECT_LABELS } from '@/lib/dialects';
const PAGE_SIZE = 1; const PAGE_SIZE = 1;
const AUTO_ADVANCE_DELAY_MS = 600; const AUTO_ADVANCE_DELAY_MS = 600;
@@ -18,11 +18,11 @@ const RATING_OPTIONS = (dialectLabel: string) => [
]; ];
interface SingleChoiceViewProps { interface SingleChoiceViewProps {
entries: AnnotationEntry[]; entries: DatasetEntryForAnnotation[];
datasetId: number; experimentId: number;
} }
export default function SingleChoiceView({ entries, datasetId }: SingleChoiceViewProps) { export default function SingleChoiceView({ entries, experimentId }: SingleChoiceViewProps) {
const [isPending, startTransition] = useTransition(); const [isPending, startTransition] = useTransition();
@@ -46,7 +46,7 @@ export default function SingleChoiceView({ entries, datasetId }: SingleChoiceVie
const timer = setTimeout(() => { const timer = setTimeout(() => {
const batch = pageEntries.map((e) => ({ entryId: e.id, rating: answers[e.id], dialectLabel: e.dialect })); const batch = pageEntries.map((e) => ({ entryId: e.id, rating: answers[e.id], dialectLabel: e.dialect }));
startTransition(async () => { startTransition(async () => {
await saveAnnotations(batch); await saveAnnotations(batch, experimentId);
if (currentPage + 1 >= totalPages) { if (currentPage + 1 >= totalPages) {
setIsComplete(true); setIsComplete(true);
} else { } else {
@@ -108,7 +108,7 @@ export default function SingleChoiceView({ entries, datasetId }: SingleChoiceVie
{pageEntries.map((entry, idx) => { {pageEntries.map((entry, idx) => {
const dialectLabel = DIALECT_LABELS[entry.dialect] ?? entry.dialect; const dialectLabel = DIALECT_LABELS[entry.dialect] ?? entry.dialect;
const fileExt = entry.fileName.substring(entry.fileName.lastIndexOf('.')); const fileExt = entry.fileName.substring(entry.fileName.lastIndexOf('.'));
const audioSrc = `/public/datasets/${datasetId}/${entry.externalId}${fileExt}`; const audioSrc = `/public/datasets/${entry.datasetId}/${entry.externalId}${fileExt}`;
const isListened = fullyPlayed.has(entry.id); const isListened = fullyPlayed.has(entry.id);
const currentRating = answers[entry.id] ?? null; const currentRating = answers[entry.id] ?? null;

View File

@@ -9,11 +9,13 @@ export const DIALECT_LABELS: Record<string, string> = {
de: 'Deutsch', de: 'Deutsch',
}; };
export type AnnotationEntry = { export type DatasetEntryForAnnotation = {
id: number; id: number;
externalId: string; externalId: string;
fileName: string; fileName: string;
dialect: string; dialect: string;
durationMs: number | null; durationMs: number | null;
datasetId: number; datasetId: number;
experimentId: number;
annotation: number | null;
}; };

View File

@@ -1,24 +1,34 @@
import { sqliteTable, text, integer, uniqueIndex } from 'drizzle-orm/sqlite-core'; import { sqliteTable, text, integer, uniqueIndex } from 'drizzle-orm/sqlite-core';
import { relations, sql } from 'drizzle-orm'; import { relations, sql } from 'drizzle-orm';
import { dataset_entry } from './dataset_entry'; import { dataset_entry } from './dataset_entry';
import { experiment } from './experiment';
export const annotation = sqliteTable( export const annotation = sqliteTable(
'annotation', 'annotation',
{ {
id: integer('id').primaryKey({ autoIncrement: true }), id: integer('id').primaryKey({ autoIncrement: true }),
datasetEntryId: integer('dataset_entry_id') datasetEntryId: integer('dataset_entry_id').notNull().references(() => dataset_entry.id),
experimentId: integer('experiment_id')
.notNull() .notNull()
.references(() => dataset_entry.id), .references(() => experiment.id),
userId: text('user_id').notNull(), userId: text('user_id').notNull(),
rating: integer('rating').notNull(), // 15 rating: integer('rating').notNull(), // 15
dialectLabel: text('dialect_label').notNull(), // e.g. 'ch_be', 'ch_zh', … dialectLabel: text('dialect_label').notNull(), // e.g. 'ch_be', 'ch_zh', …
createdAt: integer('created_at', { mode: 'timestamp' }) createdAt: integer('created_at', { mode: 'timestamp' })
.notNull() .notNull()
.default(sql`(unixepoch())`), .default(sql`(unixepoch())`),
updatedAt: integer('updated_at', { mode: 'timestamp' })
.notNull()
.default(sql`(unixepoch())`)
.$onUpdate(() => sql`(unixepoch())`),
} }
); );
export const annotationRelations = relations(annotation, ({ one }) => ({ export const annotationRelations = relations(annotation, ({ one }) => ({
experiment: one(experiment, {
fields: [annotation.experimentId],
references: [experiment.id],
}),
datasetEntry: one(dataset_entry, { datasetEntry: one(dataset_entry, {
fields: [annotation.datasetEntryId], fields: [annotation.datasetEntryId],
references: [dataset_entry.id], references: [dataset_entry.id],

View File

@@ -0,0 +1,34 @@
import { sqliteTable, text, integer, uniqueIndex } from 'drizzle-orm/sqlite-core';
import { relations, sql } from 'drizzle-orm';
import { annotation } from './annotation';
import { dataset } from './dataset';
export const experiment = sqliteTable(
'experiment',
{
id: integer('id').primaryKey({ autoIncrement: true }),
name: text('name').notNull(),
description: text('description'),
datasetId: integer('dataset_id')
.notNull()
.references(() => dataset.id),
createdAt: integer('created_at', { mode: 'timestamp' })
.notNull()
.default(sql`(unixepoch())`),
updatedAt: integer('updated_at', { mode: 'timestamp' })
.notNull()
.default(sql`(unixepoch())`)
.$onUpdate(() => sql`(unixepoch())`),
}
);
export const experimentRelations = relations(experiment, ({ one, many }) => ({
dataset: one(dataset, {
fields: [experiment.datasetId],
references: [dataset.id],
}),
annotations: many(annotation),
}));
export type Experiment = typeof experiment.$inferSelect;
export type NewExperiment = typeof experiment.$inferInsert;