Add initial audio recognition requests

This commit is contained in:
2025-08-11 15:26:55 +03:00
parent c1da998c02
commit 672d8573fc
9 changed files with 396 additions and 64 deletions

View File

@@ -21,14 +21,16 @@ func NewTranscriptJobRepository(db *sql.DB, gq *goqu.Database) *TranscriptJobRep
func (repo *TranscriptJobRepository) Create(job *entity.TranscribeJob) error {
record := goqu.Record{
"id": job.Id,
"state": job.State,
"file_id": job.FileID,
"is_error": job.IsError,
"error_text": job.ErrorText,
"worker": job.Worker,
"acquired_at": job.AcquiredAt,
"created_at": job.CreatedAt,
"id": job.Id,
"state": job.State,
"file_id": job.FileID,
"is_error": job.IsError,
"error_text": job.ErrorText,
"worker": job.Worker,
"acquired_at": job.AcquiredAt,
"created_at": job.CreatedAt,
"recognition_op_id": job.RecognitionOpID,
"transcription_text": job.TranscriptionText,
}
query := repo.gq.Insert("transcribe_jobs").Rows(record)
sql, args, err := query.ToSQL()
@@ -46,12 +48,14 @@ func (repo *TranscriptJobRepository) Create(job *entity.TranscribeJob) error {
func (repo *TranscriptJobRepository) Save(job *entity.TranscribeJob) error {
record := goqu.Record{
"state": job.State,
"file_id": job.FileID,
"is_error": job.IsError,
"error_text": job.ErrorText,
"worker": job.Worker,
"acquired_at": job.AcquiredAt,
"state": job.State,
"file_id": job.FileID,
"is_error": job.IsError,
"error_text": job.ErrorText,
"worker": job.Worker,
"acquired_at": job.AcquiredAt,
"recognition_op_id": job.RecognitionOpID,
"transcription_text": job.TranscriptionText,
}
query := repo.gq.Update("transcribe_jobs").Set(record).Where(goqu.C("id").Eq(job.Id))
sql, args, err := query.ToSQL()
@@ -77,6 +81,8 @@ func (repo *TranscriptJobRepository) GetByID(id string) (*entity.TranscribeJob,
"worker",
"acquired_at",
"created_at",
"recognition_op_id",
"transcription_text",
).Where(goqu.C("id").Eq(id))
sql, args, err := query.ToSQL()
if err != nil {
@@ -93,6 +99,8 @@ func (repo *TranscriptJobRepository) GetByID(id string) (*entity.TranscribeJob,
&job.Worker,
&job.AcquiredAt,
&job.CreatedAt,
&job.RecognitionOpID,
&job.TranscriptionText,
)
if err != nil {
return nil, fmt.Errorf("failed to get transcribe job: %w", err)
@@ -154,6 +162,8 @@ func (repo *TranscriptJobRepository) FindAndAcquire(state, acquisitionId string,
"worker",
"acquired_at",
"created_at",
"recognition_op_id",
"transcription_text",
).Where(goqu.C("worker").Eq(acquisitionId))
sql, args, err = selectQuery.ToSQL()
@@ -171,6 +181,8 @@ func (repo *TranscriptJobRepository) FindAndAcquire(state, acquisitionId string,
&job.Worker,
&job.AcquiredAt,
&job.CreatedAt,
&job.RecognitionOpID,
&job.TranscriptionText,
)
if err != nil {
return nil, fmt.Errorf("failed to get transcribe job: %w", err)