From 665cc4e0bbc620dc613b66286104b160f78309ed Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 28 Sep 2022 11:16:28 +0800 Subject: [PATCH 1/4] #2967 add log --- services/task/task.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/services/task/task.go b/services/task/task.go index 194a43649d..f13dfa5ad1 100644 --- a/services/task/task.go +++ b/services/task/task.go @@ -61,7 +61,7 @@ func Accomplish(action models.Action) { actions = append(actions, models.Action{ ID: action.ID, OpType: models.ActionDatasetRecommended, - ActUserID: action.UserID, + ActUserID: action.ActUserID, UserID: user.ID, RepoID: action.RepoID, Content: action.Content, @@ -85,7 +85,11 @@ func accomplish(action models.Action, taskType models.TaskType) error { log.Error("PANIC:%v", combinedErr) } }() + log.Info("accomplish start. actionId=%d userId= %d", action.ID, action.UserID) userId := action.UserID + if !isUserAvailable(userId) { + return nil + } //get task config config, err := GetTaskConfig(string(taskType)) @@ -143,3 +147,17 @@ func isLimited(userId int64, config *models.TaskConfig, rejectPolicy models.Limi return false } + +func isUserAvailable(userId int64) bool { + if userId < 1 { + return false + } + user, err := models.GetUserByID(userId) + if err != nil || user == nil { + return false + } + if user.IsOrganization() { + return false + } + return true +} -- 2.34.1 From beeaab76182172ee2f2f5b5a37a6d9419a9dcbdf Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 28 Sep 2022 11:57:45 +0800 Subject: [PATCH 2/4] #2967 fix bug --- services/task/task.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/task/task.go b/services/task/task.go index f13dfa5ad1..f9a6d0c0c1 100644 --- a/services/task/task.go +++ b/services/task/task.go @@ -131,7 +131,7 @@ func accomplish(action models.Action, taskType models.TaskType) error { Type: models.GetRewardTypeInstance(config.AwardType), }, TargetUserId: userId, - RequestId: fmt.Sprint(action.ID), + RequestId: fmt.Sprintf("%d_%d", action.ID, userId), OperateType: models.OperateTypeIncrease, RejectPolicy: models.FillUp, }) -- 2.34.1 From c412b6ac35a7d92607b92741f363876f4b5ca2e9 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Wed, 28 Sep 2022 14:23:53 +0800 Subject: [PATCH 3/4] #2967 fix bug --- models/reward_operate_record.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/models/reward_operate_record.go b/models/reward_operate_record.go index da1b6a589e..f201be6464 100644 --- a/models/reward_operate_record.go +++ b/models/reward_operate_record.go @@ -3,6 +3,7 @@ package models import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/timeutil" + "fmt" "strconv" "strings" "xorm.io/builder" @@ -130,21 +131,27 @@ func (l RewardRecordShowList) loadAction() error { return nil } actionIds := make([]int64, 0) - actionIdMap := make(map[int64]*RewardOperateRecordShow, 0) for _, r := range l { if r.SourceType != SourceTypeAccomplishTask.Name() { continue } i, _ := strconv.ParseInt(r.SourceId, 10, 64) actionIds = append(actionIds, i) - actionIdMap[i] = r } actions, err := GetActionByIds(actionIds) if err != nil { return err } + actionIdMap := make(map[string]*Action, 0) 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 } -- 2.34.1 From c6e116f3b16e70b4ac1e6e6a76d347ed5c3ed3f2 Mon Sep 17 00:00:00 2001 From: chenshihai Date: Wed, 28 Sep 2022 14:55:06 +0800 Subject: [PATCH 4/4] update lang --- options/locale/locale_zh-CN.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 29e9811d5e..470dd9d326 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -3092,9 +3092,9 @@ task_gputrainjob=`创建了CPU/GPU类型训练任务 %s` task_c2netgputrainjob=`创建了CPU/GPU类型训练任务 %s` binded_wechat=绑定微信 -dataset_recommended=`创建的数据集%s被设置为推荐数据集` -create_image=`提交了镜像%s` -image_recommended=`提交的镜像%s被设置为推荐镜像` +dataset_recommended=`创建的数据集 %s 被设置为推荐数据集` +create_image=`提交了镜像 %s` +image_recommended=`提交的镜像 %s 被设置为推荐镜像` update_user_avatar=更新了头像 [tool] -- 2.34.1