diff --git a/models/dataset.go b/models/dataset.go index 726a5010f..b7186ac0b 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -107,6 +107,7 @@ type SearchDatasetOptions struct { Category string Task string License string + DatasetIDs []int64 ListOptions SearchOrderBy IsOwner bool @@ -177,6 +178,12 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond { } } + if len(opts.DatasetIDs) > 0 { + subCon := builder.NewCond() + subCon = subCon.And(builder.In("dataset.id", opts.DatasetIDs)) + cond = cond.Or(subCon) + } + return cond } @@ -447,3 +454,11 @@ func IncreaseDownloadCount(datasetID int64) error { return nil } + +func GetCollaboratorDatasetIdsByUserID(userID int64) []int64 { + var datasets []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 + +} diff --git a/routers/home.go b/routers/home.go index e31bed4ff..ae184a72a 100755 --- a/routers/home.go +++ b/routers/home.go @@ -343,6 +343,12 @@ func ExploreDatasets(ctx *context.Context) { if ctx.User != nil && !ctx.User.IsAdmin { ownerID = ctx.User.ID } + var datasetsIds []int64 + if ownerID > 0 { + + datasetsIds = models.GetCollaboratorDatasetIdsByUserID(ownerID) + } + opts := &models.SearchDatasetOptions{ Keyword: keyword, IncludePublic: true, @@ -351,6 +357,7 @@ func ExploreDatasets(ctx *context.Context) { Task: task, License: license, OwnerID: ownerID, + DatasetIDs: datasetsIds, RecommendOnly: ctx.QueryBool("recommend"), ListOptions: models.ListOptions{ Page: page, diff --git a/templates/explore/datasets.tmpl b/templates/explore/datasets.tmpl index 0cfe1fd18..327c4fb98 100644 --- a/templates/explore/datasets.tmpl +++ b/templates/explore/datasets.tmpl @@ -199,7 +199,7 @@ {{else}} + style="display: flex;align-items: center;justify-content: flex-end;cursor: pointer;font-size: 12px;font-weight: normal;flex: 1;margin-left: 1.5rem;">