| @@ -3,6 +3,7 @@ package models | |||||
| import ( | import ( | ||||
| "code.gitea.io/gitea/modules/log" | "code.gitea.io/gitea/modules/log" | ||||
| "code.gitea.io/gitea/modules/timeutil" | "code.gitea.io/gitea/modules/timeutil" | ||||
| "fmt" | |||||
| "strconv" | "strconv" | ||||
| "strings" | "strings" | ||||
| "xorm.io/builder" | "xorm.io/builder" | ||||
| @@ -130,21 +131,27 @@ func (l RewardRecordShowList) loadAction() error { | |||||
| return nil | return nil | ||||
| } | } | ||||
| actionIds := make([]int64, 0) | actionIds := make([]int64, 0) | ||||
| actionIdMap := make(map[int64]*RewardOperateRecordShow, 0) | |||||
| for _, r := range l { | for _, r := range l { | ||||
| if r.SourceType != SourceTypeAccomplishTask.Name() { | if r.SourceType != SourceTypeAccomplishTask.Name() { | ||||
| continue | continue | ||||
| } | } | ||||
| i, _ := strconv.ParseInt(r.SourceId, 10, 64) | i, _ := strconv.ParseInt(r.SourceId, 10, 64) | ||||
| actionIds = append(actionIds, i) | actionIds = append(actionIds, i) | ||||
| actionIdMap[i] = r | |||||
| } | } | ||||
| actions, err := GetActionByIds(actionIds) | actions, err := GetActionByIds(actionIds) | ||||
| if err != nil { | if err != nil { | ||||
| return err | return err | ||||
| } | } | ||||
| actionIdMap := make(map[string]*Action, 0) | |||||
| for _, v := range actions { | for _, v := range actions { | ||||
| actionIdMap[v.ID].Action = v.ToShow() | |||||
| actionIdMap[fmt.Sprint(v.ID)] = v | |||||
| } | |||||
| for i, r := range l { | |||||
| act := actionIdMap[r.SourceId] | |||||
| if act != nil { | |||||
| l[i].Action = act.ToShow() | |||||
| } | |||||
| } | } | ||||
| return nil | return nil | ||||
| } | } | ||||