|
|
@@ -468,20 +468,19 @@ func MyFavoriteDataset(ctx *context.Context) { |
|
|
}) |
|
|
}) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
//If the dataset has been deleted, it will not be counted |
|
|
for _, datasetStar := range datasetStars { |
|
|
for _, datasetStar := range datasetStars { |
|
|
DatasetIsCollaborator := DatasetIsCollaborator(ctx, datasetStar.DatasetID) |
|
|
|
|
|
dataset, err := models.GetDatasetByID(datasetStar.DatasetID) |
|
|
|
|
|
|
|
|
IsExist, repo, dataset, err := IsDatasetStarExist(datasetStar) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return |
|
|
|
|
|
|
|
|
log.Error("IsDatasetStarExist error:", err.Error()) |
|
|
} |
|
|
} |
|
|
repo, err := models.GetRepositoryByID(dataset.RepoID) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if repo.OwnerID == ctx.User.ID || DatasetIsCollaborator { |
|
|
|
|
|
IsColDatasetIDs = append(IsColDatasetIDs, datasetStar.DatasetID) |
|
|
|
|
|
} else { |
|
|
|
|
|
NotColDatasetIDs = append(NotColDatasetIDs, datasetStar.DatasetID) |
|
|
|
|
|
|
|
|
if IsExist { |
|
|
|
|
|
DatasetIsCollaborator := DatasetIsCollaborator(ctx, dataset) |
|
|
|
|
|
if repo.OwnerID == ctx.User.ID || DatasetIsCollaborator { |
|
|
|
|
|
IsColDatasetIDs = append(IsColDatasetIDs, datasetStar.DatasetID) |
|
|
|
|
|
} else { |
|
|
|
|
|
NotColDatasetIDs = append(NotColDatasetIDs, datasetStar.DatasetID) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -609,35 +608,45 @@ func GetDatasetStatus(ctx *context.Context) { |
|
|
"AttachmentStatus": fmt.Sprint(attachment.DecompressState), |
|
|
"AttachmentStatus": fmt.Sprint(attachment.DecompressState), |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
func DatasetIsCollaborator(ctx *context.Context, DatasetID int64) bool { |
|
|
|
|
|
dataset, err := models.GetDatasetByID(DatasetID) |
|
|
|
|
|
|
|
|
func DatasetIsCollaborator(ctx *context.Context, dataset *models.Dataset) bool { |
|
|
|
|
|
repo, err := models.GetRepositoryByID(dataset.RepoID) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
log.Error("query dataset error:", err.Error()) |
|
|
|
|
|
return false |
|
|
|
|
|
|
|
|
log.Error("query repo error:", err.Error()) |
|
|
} else { |
|
|
} else { |
|
|
repo, err := models.GetRepositoryByID(dataset.RepoID) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Error("query repo error:", err.Error()) |
|
|
|
|
|
} else { |
|
|
|
|
|
repo.GetOwner() |
|
|
|
|
|
if ctx.User != nil { |
|
|
|
|
|
if repo.Owner.IsOrganization() { |
|
|
|
|
|
if repo.Owner.IsUserPartOfOrg(ctx.User.ID) { |
|
|
|
|
|
for _, t := range repo.Owner.Teams { |
|
|
|
|
|
if t.IsMember(ctx.User.ID) && t.HasRepository(repo.ID) { |
|
|
|
|
|
return true |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
repo.GetOwner() |
|
|
|
|
|
if ctx.User != nil { |
|
|
|
|
|
if repo.Owner.IsOrganization() { |
|
|
|
|
|
if repo.Owner.IsUserPartOfOrg(ctx.User.ID) { |
|
|
|
|
|
for _, t := range repo.Owner.Teams { |
|
|
|
|
|
if t.IsMember(ctx.User.ID) && t.HasRepository(repo.ID) { |
|
|
|
|
|
return true |
|
|
} |
|
|
} |
|
|
return false |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
return false |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
isCollaborator, _ := repo.IsCollaborator(ctx.User.ID) |
|
|
|
|
|
if isCollaborator { |
|
|
|
|
|
return true |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
isCollaborator, _ := repo.IsCollaborator(ctx.User.ID) |
|
|
|
|
|
if isCollaborator { |
|
|
|
|
|
return true |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
|
|
|
func IsDatasetStarExist(datasetStar *models.DatasetStar) (bool, *models.Repository, *models.Dataset, error) { |
|
|
|
|
|
dataset, err := models.GetDatasetByID(datasetStar.DatasetID) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Error("query dataset error:", err.Error()) |
|
|
|
|
|
return false, nil, nil, err |
|
|
|
|
|
} else { |
|
|
|
|
|
repo, err := models.GetRepositoryByID(dataset.RepoID) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Error("GetRepositoryByID error:", err.Error()) |
|
|
|
|
|
return false, nil, nil, err |
|
|
|
|
|
} |
|
|
|
|
|
return true, repo, dataset, nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |