Browse Source

Merge pull request 'fix-2144 数据集未登录下的间距, 数据集广场可以看到作为协作者的仓库数据集' (#2287) from fix-2144 into V20220616

Reviewed-on: https://git.openi.org.cn/OpenI/aiforge/pulls/2287
Reviewed-by: lewis <747342561@qq.com>
pull/2309/head
lewis 3 years ago
parent
commit
059022b70f
3 changed files with 23 additions and 1 deletions
  1. +15
    -0
      models/dataset.go
  2. +7
    -0
      routers/home.go
  3. +1
    -1
      templates/explore/datasets.tmpl

+ 15
- 0
models/dataset.go View File

@@ -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

}

+ 7
- 0
routers/home.go View File

@@ -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,


+ 1
- 1
templates/explore/datasets.tmpl View File

@@ -199,7 +199,7 @@
</span>
{{else}}
<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;">
<svg width="1.4em" height="1.4em" viewBox="0 0 32 32"


Loading…
Cancel
Save