From c7eb80ac3681e1d23196670ff6b5a594e08e50e8 Mon Sep 17 00:00:00 2001 From: liuzx Date: Thu, 10 Mar 2022 15:25:10 +0800 Subject: [PATCH 1/3] fix bug --- routers/repo/dataset.go | 10 +++++----- routers/routes/routes.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index 9c3efb3a4..5ef9f30bf 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -287,7 +287,7 @@ func DatasetAction(ctx *context.Context) { func CurrentRepoDataset(ctx *context.Context) { page := ctx.QueryInt("page") cloudbrainType := ctx.QueryInt("type") - keyword := strings.Trim(ctx.Query("search"), " ") + keyword := strings.Trim(ctx.Query("q"), " ") repo := ctx.Repo.Repository var datasetIDs []int64 @@ -330,10 +330,10 @@ func CurrentRepoDataset(ctx *context.Context) { }) } -func MyDataset(ctx *context.Context) { +func MyDatasets(ctx *context.Context) { page := ctx.QueryInt("page") cloudbrainType := ctx.QueryInt("type") - keyword := strings.Trim(ctx.Query("search"), " ") + keyword := strings.Trim(ctx.Query("q"), " ") uploaderID := ctx.User.ID datasets, count, err := models.Attachments(&models.AttachmentsOptions{ @@ -371,7 +371,7 @@ func MyDataset(ctx *context.Context) { func PublicDataset(ctx *context.Context) { page := ctx.QueryInt("page") cloudbrainType := ctx.QueryInt("type") - keyword := strings.Trim(ctx.Query("search"), " ") + keyword := strings.Trim(ctx.Query("q"), " ") datasets, count, err := models.Attachments(&models.AttachmentsOptions{ ListOptions: models.ListOptions{ @@ -408,7 +408,7 @@ func PublicDataset(ctx *context.Context) { func MyFavoriteDataset(ctx *context.Context) { page := ctx.QueryInt("page") cloudbrainType := ctx.QueryInt("type") - keyword := strings.Trim(ctx.Query("search"), " ") + keyword := strings.Trim(ctx.Query("q"), " ") var datasetIDs []int64 diff --git a/routers/routes/routes.go b/routers/routes/routes.go index 8c03824e3..a7b7c61d7 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -986,7 +986,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("/edit/:id", reqRepoDatasetWriter, repo.EditDataset) m.Post("/edit", reqRepoDatasetWriter, bindIgnErr(auth.EditDatasetForm{}), repo.EditDatasetPost) m.Get("/current_repo", reqRepoDatasetReader, repo.CurrentRepoDataset) - m.Get("/my_datasets", reqRepoDatasetReader, repo.MyDataset) + m.Get("/my_datasets", reqRepoDatasetReader, repo.MyDatasets) m.Get("/public_datasets", reqRepoDatasetReader, repo.PublicDataset) m.Get("/my_favorite", reqRepoDatasetReader, repo.MyFavoriteDataset) From 8cf36fcc3173bc543beb0e1c97e87dbcbd8141c1 Mon Sep 17 00:00:00 2001 From: liuzx Date: Thu, 10 Mar 2022 16:30:45 +0800 Subject: [PATCH 2/3] fix-bug --- routers/repo/dataset.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index 5ef9f30bf..3f5209918 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -325,8 +325,9 @@ func CurrentRepoDataset(ctx *context.Context) { return } ctx.JSON(200, map[string]string{ - "data": string(data), - "count": strconv.FormatInt(count, 10), + "result_code": "0", + "data": string(data), + "count": strconv.FormatInt(count, 10), }) } @@ -363,8 +364,9 @@ func MyDatasets(ctx *context.Context) { return } ctx.JSON(200, map[string]string{ - "data": string(data), - "count": strconv.FormatInt(count, 10), + "result_code": "0", + "data": string(data), + "count": strconv.FormatInt(count, 10), }) } @@ -400,8 +402,9 @@ func PublicDataset(ctx *context.Context) { return } ctx.JSON(200, map[string]string{ - "data": string(data), - "count": strconv.FormatInt(count, 10), + "result_code": "0", + "data": string(data), + "count": strconv.FormatInt(count, 10), }) } @@ -448,7 +451,8 @@ func MyFavoriteDataset(ctx *context.Context) { return } ctx.JSON(200, map[string]string{ - "data": string(data), - "count": strconv.FormatInt(count, 10), + "result_code": "0", + "data": string(data), + "count": strconv.FormatInt(count, 10), }) } From 915b3a6d94a294906628be64e33a7b95d732d67e Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Thu, 10 Mar 2022 17:12:38 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/dataset_star.go | 9 ++++++--- modules/context/repo.go | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/models/dataset_star.go b/models/dataset_star.go index fac08caee..5dedb2ba4 100644 --- a/models/dataset_star.go +++ b/models/dataset_star.go @@ -51,9 +51,12 @@ func StarDataset(userID, datasetID int64, star bool) error { return sess.Commit() } -func IsDatasetStaring(userID, datasetID int64) bool { - - return isDatasetStaring(x, userID, datasetID) +func IsDatasetStaringByRepoId(userID, repoID int64) bool { + dataset, _ := GetDatasetByRepo(&Repository{ID: repoID}) + if dataset == nil { + return false + } + return isDatasetStaring(x, userID, dataset.ID) } func isDatasetStaring(e Engine, userID, datasetID int64) bool { diff --git a/modules/context/repo.go b/modules/context/repo.go index 64f02c921..7c425c8c0 100755 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -475,6 +475,8 @@ func RepoAssignment() macaron.Handler { if ctx.IsSigned { ctx.Data["IsWatchingRepo"] = models.IsWatching(ctx.User.ID, repo.ID) ctx.Data["IsStaringRepo"] = models.IsStaring(ctx.User.ID, repo.ID) + + ctx.Data["IsStaringDataset"] = models.IsDatasetStaringByRepoId(ctx.User.ID, repo.ID) } if repo.IsFork {