diff --git a/modules/auth/wechat/template.go b/modules/auth/wechat/template.go index cd8e21f74..2ebd2667d 100644 --- a/modules/auth/wechat/template.go +++ b/modules/auth/wechat/template.go @@ -27,11 +27,13 @@ func SendTemplateMsg(template Template, ctx *TemplateContext, userId int64) erro } }() if !template.ShouldSend(ctx) { + log.Info("SendTemplateMsg should not Send.jobId=%d jobType=%s", ctx.Cloudbrain.ID, ctx.Cloudbrain.JobType) return nil } openId := models.GetUserWechatOpenId(userId) if openId == "" { + log.Error("Wechat openId not exist,userId=%d", userId) return errors.New("Wechat openId not exist") } req := TemplateMsgRequest{ @@ -56,5 +58,6 @@ func SendTemplateMsg(template Template, ctx *TemplateContext, userId int64) erro log.Error("SendTemplateMsg err. %v", err) return err } + log.Info("SendTemplateMsg success") return nil } diff --git a/modules/notification/wechat/wechat.go b/modules/notification/wechat/wechat.go index 81c697fc9..cd72bb54e 100644 --- a/modules/notification/wechat/wechat.go +++ b/modules/notification/wechat/wechat.go @@ -7,6 +7,7 @@ package wechat import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/auth/wechat" + "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/notification/base" ) @@ -24,8 +25,10 @@ func NewNotifier() base.Notifier { } func (*wechatNotifier) NotifyChangeCloudbrainStatus(cloudbrain *models.Cloudbrain, oldStatus string) { + log.Info("NotifyChangeCloudbrainStatus cloudbrain.id=%d cloudbrain.status=%s oldStatus=%s", cloudbrain.ID, cloudbrain.Status, oldStatus) operateType := wechat.GetJobOperateTypeFromCloudbrainStatus(cloudbrain) if operateType == "" { + log.Info("NotifyChangeCloudbrainStatus operateType is incorrect") return } template := wechat.GetTemplateFromOperateType(operateType) diff --git a/routers/api/v1/repo/modelarts.go b/routers/api/v1/repo/modelarts.go index 3294efdd1..419c6d6a4 100755 --- a/routers/api/v1/repo/modelarts.go +++ b/routers/api/v1/repo/modelarts.go @@ -154,6 +154,7 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { if job.StartTime == 0 && result.JobInfo.StartedAt > 0 { job.StartTime = timeutil.TimeStamp(result.JobInfo.StartedAt) } + oldStatus := job.Status job.Status = grampus.TransTrainJobStatus(result.JobInfo.Status) job.Duration = result.JobInfo.RunSec job.TrainJobDuration = models.ConvertDurationToStr(job.Duration) @@ -176,6 +177,9 @@ func GetModelArtsTrainJobVersion(ctx *context.APIContext) { aiCenterName = temp[1] } } + if oldStatus != job.Status { + notification.NotifyChangeCloudbrainStatus(job, oldStatus) + } err = models.UpdateTrainJobVersion(job) if err != nil { log.Error("UpdateJob failed:", err)