|
|
@@ -283,16 +283,144 @@ func DatasetAction(ctx *context.Context) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func TasksDatasetIndex(ctx *context.Context) { |
|
|
|
func CurrentRepoDataset(ctx *context.Context) { |
|
|
|
page := ctx.QueryInt("page") |
|
|
|
// repo := ctx.Repo.Repository |
|
|
|
cloudbrainType := ctx.QueryInt("type") |
|
|
|
repo := ctx.Repo.Repository |
|
|
|
var datasetIDs []int64 |
|
|
|
dataset, err := models.GetDatasetByRepo(repo) |
|
|
|
if err != nil { |
|
|
|
ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("GetDatasetByRepo failed", err))) |
|
|
|
} |
|
|
|
datasetIDs = append(datasetIDs, dataset.ID) |
|
|
|
uploaderID := ctx.User.ID |
|
|
|
datasets, count, err := models.Attachments(&models.AttachmentsOptions{ |
|
|
|
ListOptions: models.ListOptions{ |
|
|
|
Page: page, |
|
|
|
PageSize: setting.UI.IssuePagingNum, |
|
|
|
}, |
|
|
|
DatasetIDs: datasetIDs, |
|
|
|
UploaderID: uploaderID, |
|
|
|
Type: cloudbrainType, |
|
|
|
NeedIsPrivate: false, |
|
|
|
NeedRepoInfo: true, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("datasets", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
data, err := json.Marshal(datasets) |
|
|
|
if err != nil { |
|
|
|
log.Error("json.Marshal failed:", err.Error()) |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"result_code": "-1", |
|
|
|
"error_msg": err.Error(), |
|
|
|
"data": "", |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"data": string(data), |
|
|
|
"count": strconv.FormatInt(count, 10), |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
func MyDataset(ctx *context.Context) { |
|
|
|
page := ctx.QueryInt("page") |
|
|
|
cloudbrainType := ctx.QueryInt("type") |
|
|
|
|
|
|
|
uploaderID := ctx.User.ID |
|
|
|
datasets, count, err := models.Attachments(&models.AttachmentsOptions{ |
|
|
|
ListOptions: models.ListOptions{ |
|
|
|
Page: page, |
|
|
|
PageSize: setting.UI.IssuePagingNum, |
|
|
|
}, |
|
|
|
UploaderID: uploaderID, |
|
|
|
Type: cloudbrainType, |
|
|
|
NeedIsPrivate: false, |
|
|
|
NeedRepoInfo: true, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("datasets", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
data, err := json.Marshal(datasets) |
|
|
|
if err != nil { |
|
|
|
log.Error("json.Marshal failed:", err.Error()) |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"result_code": "-1", |
|
|
|
"error_msg": err.Error(), |
|
|
|
"data": "", |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"data": string(data), |
|
|
|
"count": strconv.FormatInt(count, 10), |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
func PublicDataset(ctx *context.Context) { |
|
|
|
page := ctx.QueryInt("page") |
|
|
|
cloudbrainType := ctx.QueryInt("type") |
|
|
|
|
|
|
|
datasets, count, err := models.Attachments(&models.AttachmentsOptions{ |
|
|
|
ListOptions: models.ListOptions{ |
|
|
|
Page: page, |
|
|
|
PageSize: setting.UI.IssuePagingNum, |
|
|
|
}, |
|
|
|
NeedIsPrivate: true, |
|
|
|
IsPrivate: false, |
|
|
|
Type: cloudbrainType, |
|
|
|
NeedRepoInfo: true, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("datasets", err) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
data, err := json.Marshal(datasets) |
|
|
|
if err != nil { |
|
|
|
log.Error("json.Marshal failed:", err.Error()) |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"result_code": "-1", |
|
|
|
"error_msg": err.Error(), |
|
|
|
"data": "", |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
"data": string(data), |
|
|
|
"count": strconv.FormatInt(count, 10), |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
func MyFavoriteDataset(ctx *context.Context) { |
|
|
|
page := ctx.QueryInt("page") |
|
|
|
cloudbrainType := ctx.QueryInt("type") |
|
|
|
|
|
|
|
var datasetIDs []int64 |
|
|
|
|
|
|
|
datasetStars, err := models.GetDatasetStarByUser(ctx.User) |
|
|
|
if err != nil { |
|
|
|
ctx.JSON(http.StatusOK, models.BaseErrorMessage(ctx.Tr("GetDatasetByRepo failed", err))) |
|
|
|
} |
|
|
|
for i, _ := range datasetStars { |
|
|
|
datasetIDs = append(datasetIDs, datasetStars[i].DatasetID) |
|
|
|
} |
|
|
|
|
|
|
|
datasets, count, err := models.Attachments(&models.AttachmentsOptions{ |
|
|
|
ListOptions: models.ListOptions{ |
|
|
|
Page: page, |
|
|
|
PageSize: setting.UI.IssuePagingNum, |
|
|
|
}, |
|
|
|
Type: models.TypeCloudBrainTwo, |
|
|
|
DatasetIDs: datasetIDs, |
|
|
|
NeedIsPrivate: true, |
|
|
|
IsPrivate: false, |
|
|
|
Type: cloudbrainType, |
|
|
|
NeedRepoInfo: true, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("datasets", err) |
|
|
|