Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/2287 Reviewed-by: lewis <747342561@qq.com>tags/v1.22.6.1^2
| @@ -107,6 +107,7 @@ type SearchDatasetOptions struct { | |||||
| Category string | Category string | ||||
| Task string | Task string | ||||
| License string | License string | ||||
| DatasetIDs []int64 | |||||
| ListOptions | ListOptions | ||||
| SearchOrderBy | SearchOrderBy | ||||
| IsOwner bool | 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 | return cond | ||||
| } | } | ||||
| @@ -447,3 +454,11 @@ func IncreaseDownloadCount(datasetID int64) error { | |||||
| return nil | 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 | |||||
| } | |||||
| @@ -343,6 +343,12 @@ func ExploreDatasets(ctx *context.Context) { | |||||
| if ctx.User != nil && !ctx.User.IsAdmin { | if ctx.User != nil && !ctx.User.IsAdmin { | ||||
| ownerID = ctx.User.ID | ownerID = ctx.User.ID | ||||
| } | } | ||||
| var datasetsIds []int64 | |||||
| if ownerID > 0 { | |||||
| datasetsIds = models.GetCollaboratorDatasetIdsByUserID(ownerID) | |||||
| } | |||||
| opts := &models.SearchDatasetOptions{ | opts := &models.SearchDatasetOptions{ | ||||
| Keyword: keyword, | Keyword: keyword, | ||||
| IncludePublic: true, | IncludePublic: true, | ||||
| @@ -351,6 +357,7 @@ func ExploreDatasets(ctx *context.Context) { | |||||
| Task: task, | Task: task, | ||||
| License: license, | License: license, | ||||
| OwnerID: ownerID, | OwnerID: ownerID, | ||||
| DatasetIDs: datasetsIds, | |||||
| RecommendOnly: ctx.QueryBool("recommend"), | RecommendOnly: ctx.QueryBool("recommend"), | ||||
| ListOptions: models.ListOptions{ | ListOptions: models.ListOptions{ | ||||
| Page: page, | Page: page, | ||||
| @@ -199,7 +199,7 @@ | |||||
| </span> | </span> | ||||
| {{else}} | {{else}} | ||||
| <span | <span | ||||
| style="display: flex;align-items: center;justify-content: flex-end;cursor: pointer;font-size: 12px;font-weight: normal;flex: 1;"> | |||||
| style="display: flex;align-items: center;justify-content: flex-end;cursor: pointer;font-size: 12px;font-weight: normal;flex: 1;margin-left: 1.5rem;"> | |||||
| <div style="line-height: 1;margin-right: 4px;margin-bottom: -2px;"> | <div style="line-height: 1;margin-right: 4px;margin-bottom: -2px;"> | ||||
| <svg width="1.4em" height="1.4em" viewBox="0 0 32 32" | <svg width="1.4em" height="1.4em" viewBox="0 0 32 32" | ||||