fix: 任务差额结算后 quota 和阿里视频时长优化 (#5923)
* fix: apply default ali video duration when value is non-positive * fix: persist task quota after async settlement
This commit is contained in:
@@ -417,6 +417,10 @@ func (Task *Task) Update() error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (t *Task) UpdateQuota() error {
|
||||
return DB.Model(t).Update("quota", t.Quota).Error
|
||||
}
|
||||
|
||||
// UpdateWithStatus performs a conditional UPDATE guarded by fromStatus (CAS).
|
||||
// Returns (true, nil) if this caller won the update, (false, nil) if
|
||||
// another process already moved the task out of fromStatus.
|
||||
|
||||
@@ -415,7 +415,8 @@ func (a *TaskAdaptor) convertToAliRequest(info *relaycommon.RelayInfo, req relay
|
||||
} else {
|
||||
aliReq.Parameters.Duration = seconds
|
||||
}
|
||||
} else {
|
||||
}
|
||||
if aliReq.Parameters.Duration <= 0 {
|
||||
aliReq.Parameters.Duration = 5 // 默认5秒
|
||||
}
|
||||
|
||||
|
||||
@@ -215,6 +215,9 @@ func RecalculateTaskQuota(ctx context.Context, task *model.Task, actualQuota int
|
||||
taskAdjustTokenQuota(ctx, task, quotaDelta)
|
||||
|
||||
task.Quota = actualQuota
|
||||
if err := task.UpdateQuota(); err != nil {
|
||||
logger.LogError(ctx, fmt.Sprintf("差额结算回写 quota 失败 task %s: %s", task.TaskID, err.Error()))
|
||||
}
|
||||
|
||||
var logType int
|
||||
var logQuota int
|
||||
|
||||
Reference in New Issue
Block a user