diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index ba7346481..3a5ee5f57 100755 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -738,6 +738,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Combo("/repositories/:id", reqToken()).Get(repo.GetByID) m.Group("/datasets/:username/:reponame", func() { + m.Get("", repo.CurrentRepoDatasetInfoWithoutAttachment) m.Get("/current_repo", repo.CurrentRepoDatasetMultiple) m.Get("/my_datasets", repo.MyDatasetsMultiple) m.Get("/public_datasets", repo.PublicDatasetMultiple) diff --git a/routers/api/v1/repo/datasets.go b/routers/api/v1/repo/datasets.go index 0223cf740..2dbda4fb6 100644 --- a/routers/api/v1/repo/datasets.go +++ b/routers/api/v1/repo/datasets.go @@ -51,6 +51,28 @@ func CurrentRepoDatasetMultiple(ctx *context.APIContext) { } +func CurrentRepoDatasetInfoWithoutAttachment(ctx *context.APIContext) { + dataset, err := models.GetDatasetByRepo(ctx.Repo.Repository) + + if err != nil { + log.Warn("can not get dataset.", err) + ctx.JSON(200, map[string]interface{}{ + "code": 0, + "message": "", + "data": []*api.Dataset{}, + }) + return + } + + dataset.Repo = ctx.Repo.Repository + ctx.JSON(200, map[string]interface{}{ + "code": 0, + "message": "", + "data": []*api.Dataset{convert.ToDataset(dataset)}, + }) + +} + func MyDatasetsMultiple(ctx *context.APIContext) { opts := &models.SearchDatasetOptions{