feat: add mj_action_power system config item

This commit is contained in:
RockYang
2024-03-28 09:53:41 +08:00
parent 4fb2c5803c
commit 1f964c74e9
7 changed files with 98 additions and 23 deletions

View File

@@ -162,11 +162,9 @@ func (p *ServicePool) SyncTaskProgress() {
for _, job := range items {
// 失败或者 30 分钟还没完成的任务删除并退回算力
if time.Now().Sub(job.CreatedAt) > time.Minute*30 || job.Progress == -1 {
// 删除任务
p.db.Delete(&job)
// 略过 Upscale 任务
if job.Type != types.TaskUpscale.String() {
continue
}
// 退回算力
tx := p.db.Model(&model.User{}).Where("id = ?", job.UserId).UpdateColumn("power", gorm.Expr("power + ?", job.Power))
if tx.Error == nil && tx.RowsAffected > 0 {
var user model.User