Fix job fields naiming
This commit is contained in:
@@ -26,11 +26,13 @@ func (repo *TranscriptJobRepository) Create(job *entity.TranscribeJob) error {
|
||||
"file_id": job.FileID,
|
||||
"is_error": job.IsError,
|
||||
"error_text": job.ErrorText,
|
||||
"worker": job.Worker,
|
||||
"acquired_at": job.AcquiredAt,
|
||||
"created_at": job.CreatedAt,
|
||||
"acquisition_id": job.AcquisitionID,
|
||||
"acquire_time": job.AcquireTime,
|
||||
"delay_time": job.DelayTime,
|
||||
"recognition_op_id": job.RecognitionOpID,
|
||||
"transcription_text": job.TranscriptionText,
|
||||
"created_at": job.CreatedAt,
|
||||
"updated_at": job.UpdatedAt,
|
||||
}
|
||||
query := repo.gq.Insert("transcribe_jobs").Rows(record)
|
||||
sql, args, err := query.ToSQL()
|
||||
@@ -52,10 +54,12 @@ func (repo *TranscriptJobRepository) Save(job *entity.TranscribeJob) error {
|
||||
"file_id": job.FileID,
|
||||
"is_error": job.IsError,
|
||||
"error_text": job.ErrorText,
|
||||
"worker": job.Worker,
|
||||
"acquired_at": job.AcquiredAt,
|
||||
"acquisition_id": job.AcquisitionID,
|
||||
"acquire_time": job.AcquireTime,
|
||||
"delay_time": job.DelayTime,
|
||||
"recognition_op_id": job.RecognitionOpID,
|
||||
"transcription_text": job.TranscriptionText,
|
||||
"updated_at": job.UpdatedAt,
|
||||
}
|
||||
query := repo.gq.Update("transcribe_jobs").Set(record).Where(goqu.C("id").Eq(job.Id))
|
||||
sql, args, err := query.ToSQL()
|
||||
@@ -78,11 +82,13 @@ func (repo *TranscriptJobRepository) GetByID(id string) (*entity.TranscribeJob,
|
||||
"file_id",
|
||||
"is_error",
|
||||
"error_text",
|
||||
"worker",
|
||||
"acquired_at",
|
||||
"created_at",
|
||||
"acquisition_id",
|
||||
"acquire_time",
|
||||
"delay_time",
|
||||
"recognition_op_id",
|
||||
"transcription_text",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
).Where(goqu.C("id").Eq(id))
|
||||
sql, args, err := query.ToSQL()
|
||||
if err != nil {
|
||||
@@ -96,11 +102,13 @@ func (repo *TranscriptJobRepository) GetByID(id string) (*entity.TranscribeJob,
|
||||
&job.FileID,
|
||||
&job.IsError,
|
||||
&job.ErrorText,
|
||||
&job.Worker,
|
||||
&job.AcquiredAt,
|
||||
&job.CreatedAt,
|
||||
&job.AcquisitionID,
|
||||
&job.AcquireTime,
|
||||
&job.DelayTime,
|
||||
&job.RecognitionOpID,
|
||||
&job.TranscriptionText,
|
||||
&job.CreatedAt,
|
||||
&job.UpdatedAt,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get transcribe job: %w", err)
|
||||
@@ -113,8 +121,8 @@ func (repo *TranscriptJobRepository) FindAndAcquire(state, acquisitionId string,
|
||||
updateQuery := repo.gq.Update("transcribe_jobs").
|
||||
Set(
|
||||
goqu.Record{
|
||||
"worker": acquisitionId,
|
||||
"acquired_at": time.Now(),
|
||||
"acquisition_id": acquisitionId,
|
||||
"acquire_time": time.Now(),
|
||||
},
|
||||
).
|
||||
Where(
|
||||
@@ -125,8 +133,12 @@ func (repo *TranscriptJobRepository) FindAndAcquire(state, acquisitionId string,
|
||||
goqu.C("state").Eq(state),
|
||||
goqu.C("is_error").Eq(0),
|
||||
goqu.Or(
|
||||
goqu.C("worker").IsNull(),
|
||||
goqu.C("acquired_at").Lt(rottingTime),
|
||||
goqu.C("delay_time").IsNull(),
|
||||
goqu.C("delay_time").Lt(time.Now()),
|
||||
),
|
||||
goqu.Or(
|
||||
goqu.C("acquisition_id").IsNull(),
|
||||
goqu.C("acquire_time").Lt(rottingTime),
|
||||
),
|
||||
),
|
||||
).
|
||||
@@ -159,12 +171,14 @@ func (repo *TranscriptJobRepository) FindAndAcquire(state, acquisitionId string,
|
||||
"file_id",
|
||||
"is_error",
|
||||
"error_text",
|
||||
"worker",
|
||||
"acquired_at",
|
||||
"created_at",
|
||||
"acquisition_id",
|
||||
"acquire_time",
|
||||
"delay_time",
|
||||
"recognition_op_id",
|
||||
"transcription_text",
|
||||
).Where(goqu.C("worker").Eq(acquisitionId))
|
||||
"created_at",
|
||||
"updated_at",
|
||||
).Where(goqu.C("acquisition_id").Eq(acquisitionId))
|
||||
|
||||
sql, args, err = selectQuery.ToSQL()
|
||||
if err != nil {
|
||||
@@ -178,11 +192,13 @@ func (repo *TranscriptJobRepository) FindAndAcquire(state, acquisitionId string,
|
||||
&job.FileID,
|
||||
&job.IsError,
|
||||
&job.ErrorText,
|
||||
&job.Worker,
|
||||
&job.AcquiredAt,
|
||||
&job.CreatedAt,
|
||||
&job.AcquisitionID,
|
||||
&job.AcquireTime,
|
||||
&job.DelayTime,
|
||||
&job.RecognitionOpID,
|
||||
&job.TranscriptionText,
|
||||
&job.CreatedAt,
|
||||
&job.UpdatedAt,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get transcribe job: %w", err)
|
||||
|
Reference in New Issue
Block a user