fix: fixed bug for img_call increased when upscale task run failed

This commit is contained in:
RockYang
2024-01-19 17:10:52 +08:00
parent 15b2ec9721
commit 0140713e86
3 changed files with 10 additions and 4 deletions

View File

@@ -197,8 +197,10 @@ func (p *ServicePool) SyncTaskProgress() {
// 30 分钟还没完成的任务直接删除
if time.Now().Sub(v.CreatedAt) > time.Minute*30 {
p.db.Delete(&v)
// 退回绘图次数
p.db.Model(&model.User{}).Where("id = ?", v.UserId).UpdateColumn("img_calls", gorm.Expr("img_calls + ?", 1))
// 非放大任务,退回绘图次数
if v.Type != types.TaskUpscale.String() {
p.db.Model(&model.User{}).Where("id = ?", v.UserId).UpdateColumn("img_calls", gorm.Expr("img_calls + ?", 1))
}
continue
}