From 803e8749f440c5886445ca7aa558055a43b33671 Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Fri, 17 Jun 2022 11:28:50 +0800 Subject: [PATCH 1/8] fix-2285, fix-2311 --- models/dataset.go | 8 ++++++++ routers/home.go | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/models/dataset.go b/models/dataset.go index b7186ac0b..53b63185f 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -181,6 +181,7 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond { if len(opts.DatasetIDs) > 0 { subCon := builder.NewCond() subCon = subCon.And(builder.In("dataset.id", opts.DatasetIDs)) + subCon = generateFilterCond(opts, subCon) cond = cond.Or(subCon) } @@ -460,5 +461,12 @@ func GetCollaboratorDatasetIdsByUserID(userID int64) []int64 { _ = x.Table("dataset").Join("INNER", "collaboration", "dataset.repo_id = collaboration.repo_id and collaboration.mode>0 and collaboration.user_id=?", userID). Cols("dataset.id").Find(&datasets) return datasets +} +func GetTeamDatasetIdsByUserID(userID int64) []int64 { + var datasets []int64 + _ = x.Table("dataset").Join("INNER", "team_repo", "dataset.repo_id = team_repo.repo_id"). + Join("INNER", "team_user", "team_repo.team_id=team_user.team_id and team_user.uid=?", userID). + Cols("dataset.id").Find(&datasets) + return datasets } diff --git a/routers/home.go b/routers/home.go index ae184a72a..a147a84ea 100755 --- a/routers/home.go +++ b/routers/home.go @@ -346,7 +346,9 @@ func ExploreDatasets(ctx *context.Context) { var datasetsIds []int64 if ownerID > 0 { - datasetsIds = models.GetCollaboratorDatasetIdsByUserID(ownerID) + collaboratorDatasetsIds := models.GetCollaboratorDatasetIdsByUserID(ownerID) + teamDatasetsIds := models.GetTeamDatasetIdsByUserID(ownerID) + datasetsIds = append(collaboratorDatasetsIds, teamDatasetsIds...) } opts := &models.SearchDatasetOptions{ From afa22e930c255683943b25dfd56cce5b4fad25d6 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 17 Jun 2022 17:33:25 +0800 Subject: [PATCH 2/8] =?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 --- public/home/home.js | 42 +++--------------------------------------- routers/home.go | 26 ++------------------------ 2 files changed, 5 insertions(+), 63 deletions(-) diff --git a/public/home/home.js b/public/home/home.js index 9754de0cb..7343dba0b 100755 --- a/public/home/home.js +++ b/public/home/home.js @@ -217,9 +217,9 @@ function refresh3DInfo(record){ //console.log("cloudbrain two line length=" + lines.length); var span = $('.rotation3D__line').find("span")[1]; //console.log(span); - span.innerText =record.RefName; - //$('.rotation3D__line').find("span").eq(1).text(record.RefName) - //lines[1].find("span").text(record.RefName); + if(span != null){ + span.innerText =record.RefName; + } } } @@ -452,48 +452,12 @@ function queryRecommendData(){ displayOrg(json.org); displayRepo(json.repo); displayActivity(json.image); - displayCloudBrain(json.cloudbrain) }, error:function(response) { } }); - - // $.ajax({ - // type:"GET", - // url:"/recommend/repo", - // headers: { - // authorization:token, - // }, - // dataType:"json", - // async:false, - // success:function(json){ - // displayRepo(json); - // }, - // error:function(response) { - // } - // }); - - // $.ajax({ - // type:"GET", - // url:"/recommend/imageinfo", - // headers: { - // authorization:token, - // }, - // dataType:"json", - // async:false, - // success:function(json){ - // displayActivity(json); - // }, - // error:function(response) { - // } - // }); } -function displayCloudBrain(json){ - $('#completed_task').text(json.completed_task); - $('#running_task').text(json.running_task); - $('#wait_task').text(json.wait_task); -} function displayActivity(json){ var activityDiv = document.getElementById("recommendactivity"); diff --git a/routers/home.go b/routers/home.go index ae184a72a..0746fc486 100755 --- a/routers/home.go +++ b/routers/home.go @@ -7,7 +7,6 @@ package routers import ( "bytes" - "fmt" "net/http" "strconv" "strings" @@ -758,15 +757,6 @@ func GetRankUser(index string) ([]map[string]interface{}, error) { return resultOrg, nil } -// func GetImageInfoFromPromote(ctx *context.Context) { -// imageInfo, err := GetImageInfo() -// if err != nil { -// ctx.ServerError("500", err) -// return -// } -// ctx.JSON(200, imageInfo) -// } - func GetUserRankFromPromote(ctx *context.Context) { index := ctx.Params("index") resultUserRank, err := GetRankUser(index) @@ -790,27 +780,15 @@ func RecommendHomeInfo(ctx *context.Context) { if err != nil { log.Info("error." + err.Error()) } - resultCloudBrain, err := getCloudbrainNums() - if err != nil { - log.Info("error." + err.Error()) - } + mapInterface := make(map[string]interface{}) mapInterface["org"] = resultOrg mapInterface["repo"] = resultRepo mapInterface["image"] = resultImage - mapInterface["cloudbrain"] = resultCloudBrain + //mapInterface["cloudbrain"] = resultCloudBrain ctx.JSON(http.StatusOK, mapInterface) } -func getCloudbrainNums() (map[string]string, error) { - result := make(map[string]string) - cloudStatusMap := models.GetAllStatusCloudBrain() - result["completed_task"] = fmt.Sprint(cloudStatusMap["COMPLETED"]) - result["running_task"] = fmt.Sprint(cloudStatusMap["RUNNING"]) - result["wait_task"] = fmt.Sprint(cloudStatusMap["WAITING"]) - return result, nil -} - // func RecommendOrgFromPromote(ctx *context.Context) { // resultOrg, err := GetRecommendOrg() // if err != nil { From 2d8f9d3ba5a48dc07d361c3fe91a150ca9947529 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 17 Jun 2022 17:49:35 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E6=8F=90=E9=AB=98=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E9=80=9F=E5=BA=A6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- models/user.go | 14 +++++++++++++- routers/home.go | 27 +++++++-------------------- services/repository/repository.go | 5 ----- 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/models/user.go b/models/user.go index 7d4c8ce34..dd5a6f1d2 100755 --- a/models/user.go +++ b/models/user.go @@ -6,7 +6,6 @@ package models import ( - "code.gitea.io/gitea/modules/blockchain" "container/list" "context" "crypto/md5" @@ -25,6 +24,8 @@ import ( "time" "unicode/utf8" + "code.gitea.io/gitea/modules/blockchain" + "code.gitea.io/gitea/modules/avatar" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/generate" @@ -1498,6 +1499,17 @@ func GetUsersByIDs(ids []int64) (UserList, error) { return ous, err } +func GetUsersByNames(names []string) (UserList, error) { + ous := make([]*User, 0, len(names)) + if len(names) == 0 { + return ous, nil + } + err := x.In("name", names). + Asc("name"). + Find(&ous) + return ous, err +} + // GetUserIDsByNames returns a slice of ids corresponds to names. func GetUserIDsByNames(names []string, ignoreNonExistent bool) ([]int64, error) { ids := make([]int64, 0, len(names)) diff --git a/routers/home.go b/routers/home.go index 0746fc486..5f62c97be 100755 --- a/routers/home.go +++ b/routers/home.go @@ -672,9 +672,14 @@ func getRecommendOrg() ([]map[string]interface{}, error) { if err != nil { return nil, err } - resultOrg := make([]map[string]interface{}, 0) + names := make([]string, 0) for _, userName := range result { - user, err := models.GetUserByName(userName) + names = append(names, userName) + } + users, _ := models.GetUsersByNames(names) + resultOrg := make([]map[string]interface{}, 0) + for i, _ := range result { + user := users[i] if err == nil { userMap := make(map[string]interface{}) userMap["Name"] = user.Name @@ -789,24 +794,6 @@ func RecommendHomeInfo(ctx *context.Context) { ctx.JSON(http.StatusOK, mapInterface) } -// func RecommendOrgFromPromote(ctx *context.Context) { -// resultOrg, err := GetRecommendOrg() -// if err != nil { -// ctx.ServerError("500", err) -// return -// } -// ctx.JSON(200, resultOrg) -// } - -func RecommendRepoFromPromote(ctx *context.Context) { - result, err := repository.GetRecommendRepoFromPromote("projects") - if err != nil { - ctx.ServerError("500", err) - } else { - ctx.JSON(200, result) - } -} - func HomeTerm(ctx *context.Context) { ctx.HTML(200, tplHomeTerm) } diff --git a/services/repository/repository.go b/services/repository/repository.go index 80518b666..6bf4ab283 100644 --- a/services/repository/repository.go +++ b/services/repository/repository.go @@ -131,11 +131,6 @@ func GetRecommendRepoFromPromote(filename string) ([]map[string]interface{}, err repoMap["ID"] = fmt.Sprint(repo.ID) repoMap["Name"] = repo.Name repoMap["Alias"] = repo.Alias - if repo.RepoType == models.RepoCourse { - //Load creator - repo.GetCreator() - repoMap["Creator"] = repo.Creator - } repoMap["OwnerName"] = repo.OwnerName repoMap["NumStars"] = repo.NumStars From d0124f4fa9997f243dffba9ebd0a7f3e41ccc7b7 Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 17 Jun 2022 17:55:26 +0800 Subject: [PATCH 4/8] =?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 --- templates/repo/modelarts/trainjob/show.tmpl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/templates/repo/modelarts/trainjob/show.tmpl b/templates/repo/modelarts/trainjob/show.tmpl index f22a2ce56..0facbc43b 100755 --- a/templates/repo/modelarts/trainjob/show.tmpl +++ b/templates/repo/modelarts/trainjob/show.tmpl @@ -597,8 +597,12 @@
- + +
+
+ + +
@@ -671,6 +675,14 @@ $('#JobName').val(obj.DisplayJobName).addClass('model_disabled') $('input[name="JobId"]').val(obj.JobID) $('input[name="VersionName"]').val(obj.VersionName).addClass('model_disabled') + if(obj.EngineID ==122){ + $('input[name="Engine_name"]').val("MindSpore").addClass('model_disabled'); + $('input[name="Engine"]').val(2); + } + if(obj.EngineID ==121){ + $('input[name="Engine_name"]').val("TensorFlow").addClass('model_disabled'); + $('input[name="Engine"]').val(1); + } $('.ui.dimmer').css({ "background-color": "rgb(136, 136, 136,0.7)" }) createModelName() }, From 708fbe03e3e13d838a299cfd1598f3ec263b8fbb Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 20 Jun 2022 09:26:25 +0800 Subject: [PATCH 5/8] =?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 --- routers/home.go | 10 +++++++--- templates/repo/modelarts/trainjob/show.tmpl | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/routers/home.go b/routers/home.go index 430d0c223..f0cb5a667 100755 --- a/routers/home.go +++ b/routers/home.go @@ -679,10 +679,14 @@ func getRecommendOrg() ([]map[string]interface{}, error) { names = append(names, userName) } users, _ := models.GetUsersByNames(names) + userMap := make(map[string]*models.User, 0) + for _, user := range users { + userMap[user.Name] = user + } resultOrg := make([]map[string]interface{}, 0) - for i, _ := range result { - user := users[i] - if err == nil { + for _, userName := range result { + user := userMap[userName] + if user != nil { userMap := make(map[string]interface{}) userMap["Name"] = user.Name userMap["Description"] = user.Description diff --git a/templates/repo/modelarts/trainjob/show.tmpl b/templates/repo/modelarts/trainjob/show.tmpl index 0facbc43b..674e7e859 100755 --- a/templates/repo/modelarts/trainjob/show.tmpl +++ b/templates/repo/modelarts/trainjob/show.tmpl @@ -602,7 +602,7 @@
- +
@@ -704,6 +704,8 @@ type: 'POST', data: data, success: function (res) { + $('input[name="Engine_name"]').val(""); + $('input[name="Engine"]').val(""); location.href = `/${userName}/${repoPath}/modelmanage/show_model` $('.ui.modal.second').modal('hide') }, From d72f55a3c42122f407525e9188f857c2f74ff5db Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 20 Jun 2022 09:29:44 +0800 Subject: [PATCH 6/8] =?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 --- routers/home.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routers/home.go b/routers/home.go index f0cb5a667..8829e26f4 100755 --- a/routers/home.go +++ b/routers/home.go @@ -699,7 +699,7 @@ func getRecommendOrg() ([]map[string]interface{}, error) { userMap["NumMembers"] = user.NumMembers resultOrg = append(resultOrg, userMap) } else { - log.Info("query user error," + err.Error()) + log.Info("the user not exist," + userName) } } return resultOrg, nil From 3988538ea4d4cd79b2e55e2d68e5fb16d9412f5a Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 20 Jun 2022 09:43:28 +0800 Subject: [PATCH 7/8] =?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/dataset.go | 9 --------- routers/home.go | 4 +--- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/models/dataset.go b/models/dataset.go index 53b63185f..54f89acf8 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -181,7 +181,6 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond { if len(opts.DatasetIDs) > 0 { subCon := builder.NewCond() subCon = subCon.And(builder.In("dataset.id", opts.DatasetIDs)) - subCon = generateFilterCond(opts, subCon) cond = cond.Or(subCon) } @@ -462,11 +461,3 @@ func GetCollaboratorDatasetIdsByUserID(userID int64) []int64 { Cols("dataset.id").Find(&datasets) return datasets } - -func GetTeamDatasetIdsByUserID(userID int64) []int64 { - var datasets []int64 - _ = x.Table("dataset").Join("INNER", "team_repo", "dataset.repo_id = team_repo.repo_id"). - Join("INNER", "team_user", "team_repo.team_id=team_user.team_id and team_user.uid=?", userID). - Cols("dataset.id").Find(&datasets) - return datasets -} diff --git a/routers/home.go b/routers/home.go index 8829e26f4..1ed5faaa8 100755 --- a/routers/home.go +++ b/routers/home.go @@ -345,9 +345,7 @@ func ExploreDatasets(ctx *context.Context) { var datasetsIds []int64 if ownerID > 0 { - collaboratorDatasetsIds := models.GetCollaboratorDatasetIdsByUserID(ownerID) - teamDatasetsIds := models.GetTeamDatasetIdsByUserID(ownerID) - datasetsIds = append(collaboratorDatasetsIds, teamDatasetsIds...) + datasetsIds = models.GetCollaboratorDatasetIdsByUserID(ownerID) } opts := &models.SearchDatasetOptions{ From fbbea0c3ecc629f5f7dfb75691c8b9a1534a3c95 Mon Sep 17 00:00:00 2001 From: zouap Date: Mon, 20 Jun 2022 09:46:52 +0800 Subject: [PATCH 8/8] =?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/dataset.go | 1 + 1 file changed, 1 insertion(+) diff --git a/models/dataset.go b/models/dataset.go index 54f89acf8..b7186ac0b 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -460,4 +460,5 @@ func GetCollaboratorDatasetIdsByUserID(userID int64) []int64 { _ = x.Table("dataset").Join("INNER", "collaboration", "dataset.repo_id = collaboration.repo_id and collaboration.mode>0 and collaboration.user_id=?", userID). Cols("dataset.id").Find(&datasets) return datasets + }