Browse Source

fix-bug

pull/2291/head
liuzx 3 years ago
parent
commit
d9e043b47e
1 changed files with 28 additions and 22 deletions
  1. +28
    -22
      routers/repo/dataset.go

+ 28
- 22
routers/repo/dataset.go View File

@@ -453,11 +453,10 @@ func PublicDataset(ctx *context.Context) {

func MyFavoriteDataset(ctx *context.Context) {
UserId := ctx.User.ID
page := ctx.QueryInt("page")
cloudbrainType := ctx.QueryInt("type")
keyword := strings.Trim(ctx.Query("q"), " ")
var NotColDatasetIDs []int64
var IsColDatasetIDs []int64
// var IsColDatasetIDs []int64
datasetStars, err := models.GetDatasetStarByUser(ctx.User)
if err != nil {
ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("GetDatasetStarByUser failed", err)))
@@ -481,9 +480,10 @@ func MyFavoriteDataset(ctx *context.Context) {
isCollaborator, _ := repo.IsCollaborator(ctx.User.ID)
if !isCollaborator {
NotColDatasetIDs = append(NotColDatasetIDs, datasetStar.DatasetID)
} else {
IsColDatasetIDs = append(IsColDatasetIDs, datasetStar.DatasetID)
}
// } else {
// IsColDatasetIDs = append(IsColDatasetIDs, datasetStar.DatasetID)
// }
}

NotColDatasets, NotColcount, err := models.MyFvAttachments(&models.AttachmentsOptions{
@@ -503,25 +503,31 @@ func MyFavoriteDataset(ctx *context.Context) {
return
}
//If is collaborator, there is no need to determine whether the dataset is private or public
IsColDatasets, IsColcount, err := models.MyFvAttachments(&models.AttachmentsOptions{
Keyword: keyword,
NeedDatasetIDs: true,
DatasetIDs: NotColDatasetIDs,
NeedIsPrivate: false,
Type: cloudbrainType,
JustNeedZipFile: true,
NeedRepoInfo: true,
RecommendOnly: ctx.QueryBool("recommend"),
UserId: UserId,
})
if err != nil {
ctx.ServerError("datasets", err)
return
}
datasets := merge(IsColDatasets, NotColDatasets)
count := NotColcount + IsColcount
// IsColDatasets, IsColcount, err := models.MyFvAttachments(&models.AttachmentsOptions{
// Keyword: keyword,
// NeedDatasetIDs: true,
// DatasetIDs: IsColDatasetIDs,
// NeedIsPrivate: false,
// Type: cloudbrainType,
// JustNeedZipFile: true,
// NeedRepoInfo: true,
// RecommendOnly: ctx.QueryBool("recommend"),
// UserId: UserId,
// })
// if err != nil {
// ctx.ServerError("datasets", err)
// return
// }
datasets := NotColDatasets
// datasets := merge(IsColDatasets, NotColDatasets)
// count := NotColcount + IsColcount
count := NotColcount

// sort.Slice(datasets, func(i, j int) bool {
// return datasets[i].Attachment.CreatedUnix > datasets[j].Attachment.CreatedUnix
// })

// page := ctx.QueryInt("page")
page := ctx.QueryInt("page")
if page <= 0 {
page = 1
}


Loading…
Cancel
Save