Files
Scriberr/internal/interfaces/processor.go
rishikanthc 86add0037d refactor: Replace direct database.DB calls with repository pattern in handlers, dropzone, and multitrack_processor
Phase 1: Define interfaces
- Created internal/interfaces/ package with AuthServiceInterface, TaskQueueInterface, JobProcessorInterface

Phase 2: Refactor handlers.go (21 DB calls removed)
- Replaced all database.DB calls with repository methods
- Added RefreshTokenRepository for token management
- Added new repository methods: Count, FindActiveTrackJobs, FindLatestCompletedExecution, FindByName

Phase 3: Refactor dropzone.go (3 DB calls removed)
- Added CountWithAutoTranscription to UserRepository
- Injected JobRepository and UserRepository into Service

Phase 4: Refactor multitrack_processor.go
- Changed constructor to accept *gorm.DB and JobRepository
- Updated Handler to inject MultiTrackProcessor

Updated all test files with new dependencies and mock implementations.
2025-12-16 18:21:36 -08:00

28 lines
928 B
Go

package interfaces
import (
"context"
"os/exec"
)
// JobProcessorInterface defines the contract for job processing.
// This matches the existing queue.JobProcessor interface but is centralized here.
type JobProcessorInterface interface {
// ProcessJob processes a transcription job
ProcessJob(ctx context.Context, jobID string) error
// ProcessJobWithProcess processes a job and allows registering the process for termination
ProcessJobWithProcess(ctx context.Context, jobID string, registerProcess func(*exec.Cmd)) error
}
// MultiTrackJobProcessorInterface extends JobProcessorInterface with multi-track support.
type MultiTrackJobProcessorInterface interface {
JobProcessorInterface
// TerminateMultiTrackJob terminates a multi-track job and all its individual track jobs
TerminateMultiTrackJob(jobID string) error
// IsMultiTrackJob checks if a job is a multi-track job
IsMultiTrackJob(jobID string) bool
}