feat(uploads): choose the language of a recording; record it, show it, carry it to the engines (#61)
Form field (Swedish preselected, Other = auto) read before the file part and refused before anything is spooled if outside the closed set; stored on the row (migration 021, CHECK constraint, default sv for history); carried on the Job and the worker's context; shown on the status page. Feature scenarios and the coverage map are updated, and ADR-033/034 amended. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -31,12 +31,12 @@ var ErrUploadInProgress = errors.New("store: uploaded transcript is still being
|
||||
// CreateUpload records a new upload in the queued state and returns its id.
|
||||
// hadVideo records that the file carried a video track (only its audio is used);
|
||||
// it is kept for the life of the row so the page can say so.
|
||||
func (s *Store) CreateUpload(ctx context.Context, userID, title string, hadVideo bool) (string, error) {
|
||||
func (s *Store) CreateUpload(ctx context.Context, userID, title string, lang domain.Language, hadVideo bool) (string, error) {
|
||||
var id string
|
||||
if err := s.withUser(ctx, userID, func(tx pgx.Tx) error {
|
||||
return tx.QueryRow(ctx,
|
||||
`INSERT INTO uploaded_transcripts (user_id, title, had_video) VALUES ($1, $2, $3) RETURNING id`,
|
||||
userID, title, hadVideo).Scan(&id)
|
||||
`INSERT INTO uploaded_transcripts (user_id, title, language, had_video) VALUES ($1, $2, $3, $4) RETURNING id`,
|
||||
userID, title, string(lang), hadVideo).Scan(&id)
|
||||
}); err != nil {
|
||||
return "", fmt.Errorf("store: create upload: %w", err)
|
||||
}
|
||||
@@ -221,7 +221,7 @@ func (s *Store) FailInterruptedUploads(ctx context.Context) (int, error) {
|
||||
return total, nil
|
||||
}
|
||||
|
||||
const uploadSelect = `SELECT id, user_id, title, status, content, segments, endpoint,
|
||||
const uploadSelect = `SELECT id, user_id, title, language, status, content, segments, endpoint,
|
||||
audio_seconds, error_kind, had_video, reconciliation, progress, progress_at, alive_at,
|
||||
created_at, finished_at FROM uploaded_transcripts`
|
||||
|
||||
@@ -234,11 +234,13 @@ func scanUpload(row pgx.Row, u *domain.UploadedTranscript, withText bool) error
|
||||
seconds *float64
|
||||
finished, progressAt, aliveAt *time.Time
|
||||
)
|
||||
if err := row.Scan(&u.ID, &u.UserID, &u.Title, &status, &content, &segments, &endpoint,
|
||||
var language string
|
||||
if err := row.Scan(&u.ID, &u.UserID, &u.Title, &language, &status, &content, &segments, &endpoint,
|
||||
&seconds, &errKind, &u.HadVideo, &reconciliation, &progress, &progressAt, &aliveAt,
|
||||
&u.CreatedAt, &finished); err != nil {
|
||||
return err
|
||||
}
|
||||
u.Language = domain.Language(language)
|
||||
u.Status = domain.UploadStatus(deref(status))
|
||||
u.Endpoint = deref(endpoint)
|
||||
u.ErrorKind = domain.UploadErrorKind(deref(errKind))
|
||||
|
||||
Reference in New Issue
Block a user