added experiment-table: refactored all frontend pages and services
This commit is contained in:
@@ -9,11 +9,13 @@ export const DIALECT_LABELS: Record<string, string> = {
|
||||
de: 'Deutsch',
|
||||
};
|
||||
|
||||
export type AnnotationEntry = {
|
||||
export type DatasetEntryForAnnotation = {
|
||||
id: number;
|
||||
externalId: string;
|
||||
fileName: string;
|
||||
dialect: string;
|
||||
durationMs: number | null;
|
||||
datasetId: number;
|
||||
experimentId: number;
|
||||
annotation: number | null;
|
||||
};
|
||||
|
||||
@@ -1,24 +1,34 @@
|
||||
import { sqliteTable, text, integer, uniqueIndex } from 'drizzle-orm/sqlite-core';
|
||||
import { relations, sql } from 'drizzle-orm';
|
||||
import { dataset_entry } from './dataset_entry';
|
||||
import { experiment } from './experiment';
|
||||
|
||||
export const annotation = sqliteTable(
|
||||
'annotation',
|
||||
{
|
||||
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()
|
||||
.references(() => dataset_entry.id),
|
||||
.references(() => experiment.id),
|
||||
userId: text('user_id').notNull(),
|
||||
rating: integer('rating').notNull(), // 1–5
|
||||
dialectLabel: text('dialect_label').notNull(), // e.g. 'ch_be', 'ch_zh', …
|
||||
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 annotationRelations = relations(annotation, ({ one }) => ({
|
||||
experiment: one(experiment, {
|
||||
fields: [annotation.experimentId],
|
||||
references: [experiment.id],
|
||||
}),
|
||||
datasetEntry: one(dataset_entry, {
|
||||
fields: [annotation.datasetEntryId],
|
||||
references: [dataset_entry.id],
|
||||
|
||||
34
src/lib/model/experiment.ts
Normal file
34
src/lib/model/experiment.ts
Normal 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;
|
||||
Reference in New Issue
Block a user