feat(store): CreateUpload records had_video; Get/List return it

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 18:42:50 +02:00
co-authored by Claude Sonnet 5.5
parent 603d02e504
commit 85cf89c86c
@@ -25,12 +25,14 @@ var ErrUploadNotFound = errors.New("store: uploaded transcript not found")
// superuser connection the unit tests use. // superuser connection the unit tests use.
// CreateUpload records a new upload in the queued state and returns its id. // 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 var id string
if err := s.withUser(ctx, userID, func(tx pgx.Tx) error { if err := s.withUser(ctx, userID, func(tx pgx.Tx) error {
return tx.QueryRow(ctx, return tx.QueryRow(ctx,
`INSERT INTO uploaded_transcripts (user_id, title) VALUES ($1, $2) RETURNING id`, `INSERT INTO uploaded_transcripts (user_id, title, had_video) VALUES ($1, $2, $3) RETURNING id`,
userID, title).Scan(&id) userID, title, hadVideo).Scan(&id)
}); err != nil { }); err != nil {
return "", fmt.Errorf("store: create upload: %w", err) 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, 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 // scanUpload scans one uploadSelect row. withText controls whether the transcript
// body and segments are kept (GetUpload) or dropped (ListUploads). // 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 finished *time.Time
) )
if err := row.Scan(&u.ID, &u.UserID, &u.Title, &status, &content, &segments, &endpoint, 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 return err
} }
u.Status = domain.UploadStatus(deref(status)) u.Status = domain.UploadStatus(deref(status))