Browse Source

Merge pull request 'fix-2788 可选关联数据集过滤掉本项目数据集' (#2792) from fix-2392 into V20220830

Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/2792
Reviewed-by: lewis <747342561@qq.com>
fix-2781
lewis 2 years ago
parent
commit
0217d00dcc
2 changed files with 19 additions and 10 deletions
  1. +15
    -10
      models/dataset.go
  2. +4
    -0
      routers/repo/dataset.go

+ 15
- 10
models/dataset.go View File

@@ -171,16 +171,17 @@ func (datasets DatasetList) loadAttachmentAttributes(opts *SearchDatasetOptions)
}

type SearchDatasetOptions struct {
Keyword string
OwnerID int64
User *User
RepoID int64
IncludePublic bool
RecommendOnly bool
Category string
Task string
License string
DatasetIDs []int64
Keyword string
OwnerID int64
User *User
RepoID int64
IncludePublic bool
RecommendOnly bool
Category string
Task string
License string
DatasetIDs []int64
ExcludeDatasetId int64
ListOptions
SearchOrderBy
IsOwner bool
@@ -240,6 +241,10 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond {
cond = cond.And(builder.Eq{"dataset.repo_id": opts.RepoID})
}

if opts.ExcludeDatasetId > 0 {
cond = cond.And(builder.Neq{"dataset.id": opts.ExcludeDatasetId})
}

if opts.PublicOnly {
cond = cond.And(builder.Eq{"dataset.status": DatasetStatusPublic})
cond = cond.And(builder.Eq{"attachment.is_private": false})


+ 4
- 0
routers/repo/dataset.go View File

@@ -529,6 +529,10 @@ func ReferenceDatasetAvailable(ctx *context.Context) {
NeedAttachment: false,
CloudBrainType: models.TypeCloudBrainAll,
}
dataset, _ := models.GetDatasetByRepo(&models.Repository{ID: ctx.Repo.Repository.ID})
if dataset != nil {
opts.ExcludeDatasetId = dataset.ID
}
datasetMultiple(ctx, opts)

}


Loading…
Cancel
Save