backend: remove API query and media adapter leftovers

This commit is contained in:
rishikanthc
2026-05-03 13:56:50 -07:00
parent 2602e3417c
commit 1075cc04a7
2 changed files with 0 additions and 61 deletions

View File

@@ -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

View File

@@ -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()
}