From 85cf89c86c6c0771694a656afa918a0b1013cfc5 Mon Sep 17 00:00:00 2001 From: Mathias Date: Thu, 1 Oct 2026 18:42:50 +0200 Subject: [PATCH] feat(store): CreateUpload records had_video; Get/List return it Co-Authored-By: Claude Sonnet 5.5 --- internal/adapters/store/uploaded_transcripts.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/adapters/store/uploaded_transcripts.go b/internal/adapters/store/uploaded_transcripts.go index 7252761..9e2cc81 100644 --- a/internal/adapters/store/uploaded_transcripts.go +++ b/internal/adapters/store/uploaded_transcripts.go @@ -25,12 +25,14 @@ var ErrUploadNotFound = errors.New("store: uploaded transcript not found") // superuser connection the unit tests use. // CreateUpload records a new upload in the queued state and returns its id. -func (s *Store) CreateUpload(ctx context.Context, userID, title string) (string, error) { +// 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) { 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) VALUES ($1, $2) RETURNING id`, - userID, title).Scan(&id) + `INSERT INTO uploaded_transcripts (user_id, title, had_video) VALUES ($1, $2, $3) RETURNING id`, + userID, title, hadVideo).Scan(&id) }); err != nil { return "", fmt.Errorf("store: create upload: %w", err) } @@ -155,7 +157,7 @@ func (s *Store) FailInterruptedUploads(ctx context.Context) (int, error) { } const uploadSelect = `SELECT id, user_id, title, status, content, segments, endpoint, - audio_seconds, error_kind, created_at, finished_at FROM uploaded_transcripts` + audio_seconds, error_kind, had_video, created_at, finished_at FROM uploaded_transcripts` // scanUpload scans one uploadSelect row. withText controls whether the transcript // body and segments are kept (GetUpload) or dropped (ListUploads). @@ -167,7 +169,7 @@ func scanUpload(row pgx.Row, u *domain.UploadedTranscript, withText bool) error finished *time.Time ) if err := row.Scan(&u.ID, &u.UserID, &u.Title, &status, &content, &segments, &endpoint, - &seconds, &errKind, &u.CreatedAt, &finished); err != nil { + &seconds, &errKind, &u.HadVideo, &u.CreatedAt, &finished); err != nil { return err } u.Status = domain.UploadStatus(deref(status))