diff --git a/internal/api/list_query.go b/internal/api/list_query.go index f914723a..0f864e62 100644 --- a/internal/api/list_query.go +++ b/internal/api/list_query.go @@ -11,7 +11,6 @@ import ( "scriberr/internal/models" "github.com/gin-gonic/gin" - "gorm.io/gorm" ) const ( @@ -91,42 +90,6 @@ func parseSort(raw string, allowed map[string]string) (string, bool, bool) { return column, desc, ok } -func applyListQuery(query *gorm.DB, opts *listQuery) *gorm.DB { - if opts.Query != "" { - query = query.Where("LOWER(COALESCE(title, '')) LIKE ?", "%"+strings.ToLower(opts.Query)+"%") - } - if opts.UpdatedAfter != nil { - query = query.Where("updated_at > ?", *opts.UpdatedAfter) - } - if opts.Cursor != nil { - query = applyCursor(query, opts) - } - direction := "ASC" - comparisonDirection := "asc" - if opts.SortDesc { - direction = "DESC" - comparisonDirection = "desc" - } - return query.Order(opts.SortColumn + " " + direction).Order("id " + comparisonDirection).Limit(opts.Limit + 1) -} - -func applyCursor(query *gorm.DB, opts *listQuery) *gorm.DB { - operator := ">" - if opts.SortDesc { - operator = "<" - } - switch opts.SortColumn { - case "created_at", "updated_at": - value, err := time.Parse(time.RFC3339Nano, opts.Cursor.Value) - if err != nil { - return query.Where("1 = 0") - } - return query.Where("("+opts.SortColumn+" "+operator+" ?) OR ("+opts.SortColumn+" = ? AND id "+operator+" ?)", value, value, opts.Cursor.ID) - default: - return query.Where("("+opts.SortColumn+" "+operator+" ?) OR ("+opts.SortColumn+" = ? AND id "+operator+" ?)", opts.Cursor.Value, opts.Cursor.Value, opts.Cursor.ID) - } -} - func trimListPage(jobs []models.TranscriptionJob, opts *listQuery) ([]models.TranscriptionJob, any) { if len(jobs) <= opts.Limit { return jobs, nil diff --git a/internal/api/media_extractor.go b/internal/api/media_extractor.go deleted file mode 100644 index a624c259..00000000 --- a/internal/api/media_extractor.go +++ /dev/null @@ -1,24 +0,0 @@ -package api - -import ( - "context" - "os/exec" -) - -type MediaExtractor interface { - ExtractAudio(ctx context.Context, inputPath, outputPath string) error -} - -type ffmpegMediaExtractor struct{} - -func (ffmpegMediaExtractor) ExtractAudio(ctx context.Context, inputPath, outputPath string) error { - cmd := exec.CommandContext(ctx, "ffmpeg", - "-y", - "-i", inputPath, - "-vn", - "-acodec", "libmp3lame", - "-q:a", "2", - outputPath, - ) - return cmd.Run() -}