From 388071465493e8574b678861b3edd1c8fa9c99db Mon Sep 17 00:00:00 2001 From: lewis <747342561@qq.com> Date: Mon, 29 Nov 2021 17:05:32 +0800 Subject: [PATCH 1/4] fix 902 --- models/user.go | 1 + modules/context/auth.go | 3 +-- modules/context/context.go | 1 + routers/api/v1/api.go | 20 ++++++++++++-------- routers/routes/routes.go | 2 +- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/models/user.go b/models/user.go index 1ee20d74c..8968f7c02 100755 --- a/models/user.go +++ b/models/user.go @@ -145,6 +145,7 @@ type User struct { AllowImportLocal bool // Allow migrate repository by local path AllowCreateOrganization bool `xorm:"DEFAULT true"` ProhibitLogin bool `xorm:"NOT NULL DEFAULT false"` + IsOperator bool `xorm:"NOT NULL DEFAULT false"` //运营人员 // Avatar Avatar string `xorm:"VARCHAR(2048) NOT NULL"` diff --git a/modules/context/auth.go b/modules/context/auth.go index 3f53e6fce..9877657eb 100755 --- a/modules/context/auth.go +++ b/modules/context/auth.go @@ -145,8 +145,7 @@ func Toggle(options *ToggleOptions) macaron.Handler { } if options.OperationRequired { - //todo: add isOperator judgement - if !ctx.User.IsAdmin { + if !ctx.User.IsOperator { ctx.Error(403) return } diff --git a/modules/context/context.go b/modules/context/context.go index 6877780e3..5f09e190d 100755 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -310,6 +310,7 @@ func Contexter() macaron.Handler { ctx.Data["SignedUserID"] = ctx.User.ID ctx.Data["SignedUserName"] = ctx.User.Name ctx.Data["IsAdmin"] = ctx.User.IsAdmin + ctx.Data["IsOperator"] = ctx.User.IsOperator c.Data["SignedUserName"] = ctx.User.Name } else { ctx.Data["SignedUserID"] = int64(0) diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index b7ef8d48f..518c63e4f 100755 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -75,6 +75,7 @@ import ( "code.gitea.io/gitea/routers/api/v1/repo" _ "code.gitea.io/gitea/routers/api/v1/swagger" // for swagger generation "code.gitea.io/gitea/routers/api/v1/user" + repo_ext "code.gitea.io/gitea/routers/repo" "gitea.com/macaron/binding" "gitea.com/macaron/macaron" @@ -523,23 +524,26 @@ func RegisterRoutes(m *macaron.Macaron) { Get(notify.GetThread). Patch(notify.ReadThread) }, reqToken()) - adminReq := context.Toggle(&context.ToggleOptions{SignInRequired: true, AdminRequired: true}) + + operationReq := context.Toggle(&context.ToggleOptions{SignInRequired: true, OperationRequired: true}) //Project board m.Group("/projectboard", func() { - m.Get("/restoreFork", adminReq, repo.RestoreForkNumber) - m.Get("/downloadAll", adminReq, repo.ServeAllProjectsPeriodStatisticsFile) - m.Get("/downloadAllOpenI", adminReq, repo.ServeAllProjectsOpenIStatisticsFile) + m.Get("/restoreFork", repo.RestoreForkNumber) + m.Get("/downloadAll", repo.ServeAllProjectsPeriodStatisticsFile) + m.Get("/downloadAllOpenI", repo.ServeAllProjectsOpenIStatisticsFile) m.Group("/project", func() { - m.Get("", adminReq, repo.GetAllProjectsPeriodStatistics) + m.Get("", repo.GetAllProjectsPeriodStatistics) m.Group("/:id", func() { - m.Get("", adminReq, repo.GetProjectLatestStatistics) - m.Get("/period", adminReq, repo.GetProjectPeriodStatistics) + m.Get("", repo.GetProjectLatestStatistics) + m.Get("/period", repo.GetProjectPeriodStatistics) }) }) - }) + }, operationReq) + + m.Get("/query_user_static_page", operationReq, repo_ext.QueryUserStaticDataPage) // Users m.Group("/users", func() { diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 3bacb7549..67794bf88 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -792,7 +792,7 @@ func RegisterRoutes(m *macaron.Macaron) { }, reqSignIn, context.RepoAssignment(), context.UnitTypes(), reqRepoAdmin, context.RepoRef()) m.Post("/:username/:reponame/action/:action", reqSignIn, context.RepoAssignment(), context.UnitTypes(), repo.Action) - m.Get("/tool/query_user_static_page", adminReq, repo.QueryUserStaticDataPage) + // Grouping for those endpoints not requiring authentication m.Group("/:username/:reponame", func() { m.Get("/contributors", repo.Contributors) From ef4f5e0d84408e520476d92b200d5eda2151458b Mon Sep 17 00:00:00 2001 From: Gitea Date: Wed, 1 Dec 2021 09:07:06 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E5=AD=97?= =?UTF-8?q?=E7=9C=8B=E6=9D=BF=E8=AE=BF=E9=97=AE=E6=9D=83=E9=99=90=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E5=88=86=E6=9E=90=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E5=90=8E=E7=AB=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/base/head_navbar.tmpl | 4 ++-- templates/base/head_navbar_fluid.tmpl | 4 ++-- templates/base/head_navbar_home.tmpl | 4 ++-- web_src/js/components/UserAnalysis.vue | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/templates/base/head_navbar.tmpl b/templates/base/head_navbar.tmpl index 49b3181e7..c0c1aff35 100755 --- a/templates/base/head_navbar.tmpl +++ b/templates/base/head_navbar.tmpl @@ -37,7 +37,7 @@ {{.i18n.Tr "explore.users"}} {{.i18n.Tr "explore.organizations"}} {{.i18n.Tr "explore.images"}} - {{if .IsAdmin}} + {{if .IsOperator}} {{.i18n.Tr "explore.data_analysis"}} {{end}} @@ -55,7 +55,7 @@ {{.i18n.Tr "explore.users"}} {{.i18n.Tr "explore.organizations"}} {{.i18n.Tr "explore.images"}} - {{if .IsAdmin}} + {{if .IsOperator}} {{.i18n.Tr "explore.data_analysis"}} {{end}} diff --git a/templates/base/head_navbar_fluid.tmpl b/templates/base/head_navbar_fluid.tmpl index 11f5e70da..3b44babaa 100644 --- a/templates/base/head_navbar_fluid.tmpl +++ b/templates/base/head_navbar_fluid.tmpl @@ -37,7 +37,7 @@ {{.i18n.Tr "explore.users"}} {{.i18n.Tr "explore.organizations"}} {{.i18n.Tr "explore.images"}} - {{if .IsAdmin}} + {{if .IsOperator}} {{.i18n.Tr "explore.data_analysis"}} {{end}} @@ -55,7 +55,7 @@ {{.i18n.Tr "explore.users"}} {{.i18n.Tr "explore.organizations"}} {{.i18n.Tr "explore.images"}} - {{if .IsAdmin}} + {{if .IsOperator}} {{.i18n.Tr "explore.data_analysis"}} {{end}} diff --git a/templates/base/head_navbar_home.tmpl b/templates/base/head_navbar_home.tmpl index c94ff269f..8bbeebec8 100644 --- a/templates/base/head_navbar_home.tmpl +++ b/templates/base/head_navbar_home.tmpl @@ -29,7 +29,7 @@ {{.i18n.Tr "explore.users"}} {{.i18n.Tr "explore.organizations"}} {{.i18n.Tr "explore.images"}} - {{if .IsAdmin}} + {{if .IsOperator}} {{.i18n.Tr "explore.data_analysis"}} {{end}} @@ -47,7 +47,7 @@ {{.i18n.Tr "explore.users"}} {{.i18n.Tr "explore.organizations"}} {{.i18n.Tr "explore.images"}} - {{if .IsAdmin}} + {{if .IsOperator}} {{.i18n.Tr "explore.data_analysis"}} {{end}} diff --git a/web_src/js/components/UserAnalysis.vue b/web_src/js/components/UserAnalysis.vue index f5a0bb4db..beb4de8e9 100755 --- a/web_src/js/components/UserAnalysis.vue +++ b/web_src/js/components/UserAnalysis.vue @@ -27,10 +27,10 @@ - + - 下载报告 + 下载报告 下载报告 @@ -335,7 +335,7 @@ } }; - this.$axios.get('../tool/query_user_static_page',{ + this.$axios.get('../api/v1/query_user_static_page',{ params:this.params }).then((res)=>{ this.tableData = res.data.data From 4b0ef4f669d431f52b3e76a162b5332f535c09d1 Mon Sep 17 00:00:00 2001 From: liuzx Date: Wed, 1 Dec 2021 14:51:03 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/repo/modelarts.go | 65 ++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 35 deletions(-) diff --git a/routers/repo/modelarts.go b/routers/repo/modelarts.go index 069a1a0b5..81b753674 100755 --- a/routers/repo/modelarts.go +++ b/routers/repo/modelarts.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "io" - "io/ioutil" "net/http" "os" "path" @@ -382,7 +381,7 @@ func trainJobNewDataPrepare(ctx *context.Context) error { return nil } -func ErrorNewDataPrepare(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) error { +func trainJobErrorNewDataPrepare(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) error { ctx.Data["PageIsCloudBrain"] = true //can, err := canUserCreateTrainJob(ctx.User.ID) @@ -570,7 +569,7 @@ func trainJobNewVersionDataPrepare(ctx *context.Context) error { return nil } -func VersionErrorDataPrepare(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) error { +func versionErrorDataPrepare(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) error { ctx.Data["PageIsCloudBrain"] = true var jobID = ctx.Params(":jobid") // var versionName = ctx.Params(":version-name") @@ -686,22 +685,23 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) if err := paramCheckCreateTrainJob(form); err != nil { log.Error("paramCheckCreateTrainJob failed:(%v)", err) - ErrorNewDataPrepare(ctx, form) + trainJobErrorNewDataPrepare(ctx, form) ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobNew, &form) return } - attach, err := models.GetAttachmentByUUID(uuid) - if err != nil { - log.Error("GetAttachmentByUUID(%s) failed:%v", uuid, err.Error()) - return - } + // attach, err := models.GetAttachmentByUUID(uuid) + // if err != nil { + // log.Error("GetAttachmentByUUID(%s) failed:%v", uuid, err.Error()) + // return + // } //todo: del the codeLocalPath - _, err = ioutil.ReadDir(codeLocalPath) - if err == nil { - os.RemoveAll(codeLocalPath) - } + // _, err := ioutil.ReadDir(codeLocalPath) + // if err == nil { + // os.RemoveAll(codeLocalPath) + // } + os.RemoveAll(codeLocalPath) gitRepo, _ := git.OpenRepository(repo.RepoPath()) commitID, _ := gitRepo.GetBranchCommitID(branch_name) @@ -710,7 +710,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) Branch: branch_name, }); err != nil { log.Error("创建任务失败,服务器超时!: %s (%v)", repo.FullName(), err) - trainJobNewDataPrepare(ctx) + trainJobErrorNewDataPrepare(ctx, form) ctx.RenderWithErr("创建任务失败,服务器超时!", tplModelArtsTrainJobNew, &form) return } @@ -718,14 +718,14 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) //todo: upload code (send to file_server todo this work?) if err := obsMkdir(setting.CodePathPrefix + jobName + modelarts.OutputPath + VersionOutputPath + "/"); err != nil { log.Error("Failed to obsMkdir_output: %s (%v)", repo.FullName(), err) - trainJobNewDataPrepare(ctx) + trainJobErrorNewDataPrepare(ctx, form) ctx.RenderWithErr("Failed to obsMkdir_output", tplModelArtsTrainJobNew, &form) return } if err := obsMkdir(setting.CodePathPrefix + jobName + modelarts.LogPath + VersionOutputPath + "/"); err != nil { log.Error("Failed to obsMkdir_log: %s (%v)", repo.FullName(), err) - trainJobNewDataPrepare(ctx) + trainJobErrorNewDataPrepare(ctx, form) ctx.RenderWithErr("Failed to obsMkdir_log", tplModelArtsTrainJobNew, &form) return } @@ -734,7 +734,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) if err := uploadCodeToObs(codeLocalPath, jobName, ""); err != nil { // if err := uploadCodeToObs(codeLocalPath, jobName, parentDir); err != nil { log.Error("Failed to uploadCodeToObs: %s (%v)", repo.FullName(), err) - trainJobNewDataPrepare(ctx) + trainJobErrorNewDataPrepare(ctx, form) ctx.RenderWithErr("Failed to uploadCodeToObs", tplModelArtsTrainJobNew, &form) return } @@ -754,7 +754,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) err := json.Unmarshal([]byte(params), ¶meters) if err != nil { log.Error("Failed to Unmarshal params: %s (%v)", params, err) - trainJobNewDataPrepare(ctx) + trainJobErrorNewDataPrepare(ctx, form) ctx.RenderWithErr("运行参数错误", tplModelArtsTrainJobNew, &form) return } @@ -797,7 +797,7 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) if err != nil { log.Error("Failed to CreateTrainJobConfig: %v", err) - trainJobNewDataPrepare(ctx) + trainJobErrorNewDataPrepare(ctx, form) ctx.RenderWithErr("保存作业参数失败:"+err.Error(), tplModelArtsTrainJobNew, &form) return } @@ -835,15 +835,10 @@ func TrainJobCreate(ctx *context.Context, form auth.CreateModelArtsTrainJobForm) return } - err = modelarts.GenerateTrainJob(ctx, req) + err := modelarts.GenerateTrainJob(ctx, req) if err != nil { log.Error("GenerateTrainJob failed:%v", err.Error()) - trainJobNewDataPrepare(ctx) - ctx.Data["bootFile"] = form.BootFile - ctx.Data["uuid"] = form.Attachment - ctx.Data["datasetName"] = attach.Name - ctx.Data["params"] = Parameters.Parameter - ctx.Data["branch_name"] = branch_name + trainJobErrorNewDataPrepare(ctx, form) ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobNew, &form) return } @@ -892,7 +887,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ if err := paramCheckCreateTrainJob(form); err != nil { log.Error("paramCheckCreateTrainJob failed:(%v)", err) - VersionErrorDataPrepare(ctx, form) + versionErrorDataPrepare(ctx, form) ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobVersionNew, &form) return } @@ -916,7 +911,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ Branch: branch_name, }); err != nil { log.Error("创建任务失败,任务名称已存在!: %s (%v)", repo.FullName(), err) - VersionErrorDataPrepare(ctx, form) + versionErrorDataPrepare(ctx, form) ctx.RenderWithErr("创建任务失败,任务名称已存在!", tplModelArtsTrainJobVersionNew, &form) return } @@ -924,14 +919,14 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ //todo: upload code (send to file_server todo this work?) if err := obsMkdir(setting.CodePathPrefix + jobName + modelarts.OutputPath + VersionOutputPath + "/"); err != nil { log.Error("Failed to obsMkdir_output: %s (%v)", repo.FullName(), err) - VersionErrorDataPrepare(ctx, form) + versionErrorDataPrepare(ctx, form) ctx.RenderWithErr("Failed to obsMkdir_output", tplModelArtsTrainJobVersionNew, &form) return } if err := obsMkdir(setting.CodePathPrefix + jobName + modelarts.LogPath + VersionOutputPath + "/"); err != nil { log.Error("Failed to obsMkdir_log: %s (%v)", repo.FullName(), err) - VersionErrorDataPrepare(ctx, form) + versionErrorDataPrepare(ctx, form) ctx.RenderWithErr("Failed to obsMkdir_log", tplModelArtsTrainJobVersionNew, &form) return } @@ -941,7 +936,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ // if err := uploadCodeToObs(codeLocalPath, jobName, ""); err != nil { if err := uploadCodeToObs(codeLocalPath, jobName, parentDir); err != nil { log.Error("Failed to uploadCodeToObs: %s (%v)", repo.FullName(), err) - VersionErrorDataPrepare(ctx, form) + versionErrorDataPrepare(ctx, form) ctx.RenderWithErr("Failed to uploadCodeToObs", tplModelArtsTrainJobVersionNew, &form) return } @@ -961,7 +956,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ err := json.Unmarshal([]byte(params), ¶meters) if err != nil { log.Error("Failed to Unmarshal params: %s (%v)", params, err) - VersionErrorDataPrepare(ctx, form) + versionErrorDataPrepare(ctx, form) ctx.RenderWithErr("运行参数错误", tplModelArtsTrainJobVersionNew, &form) return } @@ -980,7 +975,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ if isSaveParam == "on" { if form.ParameterTemplateName == "" { log.Error("ParameterTemplateName is empty") - VersionErrorDataPrepare(ctx, form) + versionErrorDataPrepare(ctx, form) ctx.RenderWithErr("保存作业参数时,作业参数名称不能为空", tplModelArtsTrainJobVersionNew, &form) return } @@ -1004,7 +999,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ if err != nil { log.Error("Failed to CreateTrainJobConfig: %v", err) - VersionErrorDataPrepare(ctx, form) + versionErrorDataPrepare(ctx, form) ctx.RenderWithErr("保存作业参数失败:"+err.Error(), tplModelArtsTrainJobVersionNew, &form) return } @@ -1051,7 +1046,7 @@ func TrainJobCreateVersion(ctx *context.Context, form auth.CreateModelArtsTrainJ err = modelarts.GenerateTrainJobVersion(ctx, req, jobID) if err != nil { log.Error("GenerateTrainJob failed:%v", err.Error()) - VersionErrorDataPrepare(ctx, form) + versionErrorDataPrepare(ctx, form) ctx.RenderWithErr(err.Error(), tplModelArtsTrainJobVersionNew, &form) return } From b4e096277dbaff3bb7ff08e40c7ddc7360181cc1 Mon Sep 17 00:00:00 2001 From: zouap Date: Wed, 1 Dec 2021 15:44:00 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/ai_model_manage.go | 47 +++++++++++++++++---------------- routers/repo/ai_model_manage.go | 43 +++++++++++++++--------------- 2 files changed, 46 insertions(+), 44 deletions(-) diff --git a/models/ai_model_manage.go b/models/ai_model_manage.go index 00f844881..8f4fbd113 100644 --- a/models/ai_model_manage.go +++ b/models/ai_model_manage.go @@ -11,29 +11,30 @@ import ( ) type AiModelManage struct { - ID string `xorm:"pk"` - Name string `xorm:"NOT NULL"` - Version string `xorm:"NOT NULL"` - VersionCount int `xorm:"NOT NULL DEFAULT 0"` - New int `xorm:"NOT NULL"` - Type int `xorm:"NOT NULL"` - Size int64 `xorm:"NOT NULL"` - Description string `xorm:"varchar(2000)"` - Label string `xorm:"varchar(1000)"` - Path string `xorm:"varchar(400) NOT NULL"` - DownloadCount int `xorm:"NOT NULL DEFAULT 0"` - Engine int64 `xorm:"NOT NULL DEFAULT 0"` - Status int `xorm:"NOT NULL DEFAULT 0"` - Accuracy string `xorm:"varchar(1000)"` - AttachmentId string `xorm:"NULL"` - RepoId int64 `xorm:"NULL"` - CodeBranch string `xorm:"varchar(400) NULL"` - CodeCommitID string `xorm:"NULL"` - UserId int64 `xorm:"NOT NULL"` - UserName string `xorm:"NULL"` - TrainTaskInfo string `xorm:"text NULL"` - CreatedUnix timeutil.TimeStamp `xorm:"created"` - UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` + ID string `xorm:"pk"` + Name string `xorm:"NOT NULL"` + Version string `xorm:"NOT NULL"` + VersionCount int `xorm:"NOT NULL DEFAULT 0"` + New int `xorm:"NOT NULL"` + Type int `xorm:"NOT NULL"` + Size int64 `xorm:"NOT NULL"` + Description string `xorm:"varchar(2000)"` + Label string `xorm:"varchar(1000)"` + Path string `xorm:"varchar(400) NOT NULL"` + DownloadCount int `xorm:"NOT NULL DEFAULT 0"` + Engine int64 `xorm:"NOT NULL DEFAULT 0"` + Status int `xorm:"NOT NULL DEFAULT 0"` + Accuracy string `xorm:"varchar(1000)"` + AttachmentId string `xorm:"NULL"` + RepoId int64 `xorm:"NULL"` + CodeBranch string `xorm:"varchar(400) NULL"` + CodeCommitID string `xorm:"NULL"` + UserId int64 `xorm:"NOT NULL"` + UserName string `xorm:"NULL"` + UserRelAvatarLink string `xorm:"NULL"` + TrainTaskInfo string `xorm:"text NULL"` + CreatedUnix timeutil.TimeStamp `xorm:"created"` + UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` } type AiModelQueryOptions struct { diff --git a/routers/repo/ai_model_manage.go b/routers/repo/ai_model_manage.go index a02561e02..e551df260 100644 --- a/routers/repo/ai_model_manage.go +++ b/routers/repo/ai_model_manage.go @@ -25,7 +25,7 @@ const ( MODEL_NOT_LATEST = 0 ) -func saveModelByParameters(jobId string, versionName string, name string, version string, label string, description string, userId int64, userName string) error { +func saveModelByParameters(jobId string, versionName string, name string, version string, label string, description string, userId int64, userName string, userHeadUrl string) error { aiTask, err := models.GetCloudbrainByJobIDAndVersionName(jobId, versionName) //aiTask, err := models.GetCloudbrainByJobID(jobId) if err != nil { @@ -69,25 +69,26 @@ func saveModelByParameters(jobId string, versionName string, name string, versio //taskConfigInfo,err := models.GetCloudbrainByJobIDAndVersionName(jobId,aiTask.VersionName) model := &models.AiModelManage{ - ID: id, - Version: version, - VersionCount: len(aimodels) + 1, - Label: label, - Name: name, - Description: description, - New: MODEL_LATEST, - Type: cloudType, - Path: modelPath, - Size: modelSize, - AttachmentId: aiTask.Uuid, - RepoId: aiTask.RepoID, - UserId: userId, - UserName: userName, - CodeBranch: aiTask.BranchName, - CodeCommitID: aiTask.CommitID, - Engine: aiTask.EngineID, - TrainTaskInfo: string(aiTaskJson), - Accuracy: string(accuracyJson), + ID: id, + Version: version, + VersionCount: len(aimodels) + 1, + Label: label, + Name: name, + Description: description, + New: MODEL_LATEST, + Type: cloudType, + Path: modelPath, + Size: modelSize, + AttachmentId: aiTask.Uuid, + RepoId: aiTask.RepoID, + UserId: userId, + UserName: userName, + UserRelAvatarLink: userHeadUrl, + CodeBranch: aiTask.BranchName, + CodeCommitID: aiTask.CommitID, + Engine: aiTask.EngineID, + TrainTaskInfo: string(aiTaskJson), + Accuracy: string(accuracyJson), } err = models.SaveModelToDb(model) @@ -123,7 +124,7 @@ func SaveModel(ctx *context.Context) { return } - err := saveModelByParameters(JobId, VersionName, name, version, label, description, ctx.User.ID, ctx.User.Name) + err := saveModelByParameters(JobId, VersionName, name, version, label, description, ctx.User.ID, ctx.User.Name, ctx.User.RelAvatarLink()) if err != nil { log.Info("save model error." + err.Error())