From 8bb074d26ef337ef99b50bf52e8c7f98faaaba07 Mon Sep 17 00:00:00 2001 From: StardustDL Date: Wed, 22 Jul 2020 10:17:48 +0800 Subject: [PATCH] adjust count api --- .github/workflows/cd.yml | 2 +- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 2 +- src/repositories/comment.go | 5 ++++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 1fbcb51..9a46127 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -11,7 +11,7 @@ defaults: env: go-version: "1.14" dotnet-version: "3.1.x" - build_version: "0.0.3.${{ github.run_number }}-preview" + build_version: "0.0.4.${{ github.run_number }}-preview" jobs: pub-images: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e92c322..3a97e3b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ defaults: env: go-version: "1.14" dotnet-version: "3.1.x" - build_version: "0.0.3.${{ github.run_number }}-preview" + build_version: "0.0.4.${{ github.run_number }}-preview" jobs: ci: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ced27a1..e1f842d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ defaults: env: dotnet-version: "3.1.x" - build_version: "0.0.3" + build_version: "0.0.4" go-version: "1.14" jobs: diff --git a/src/repositories/comment.go b/src/repositories/comment.go index 58ad689..da2ee4a 100644 --- a/src/repositories/comment.go +++ b/src/repositories/comment.go @@ -127,7 +127,10 @@ func (repo *CommentRepository) Count(query *models.CommentQuery) (int64, error) if query.Email != "" { session = session.Where("Email = ?", query.Email) } + if query.Limit == 0 { + query.Limit = 10 + } cmt := new(models.Comment) - total, err := session.Count(cmt) + total, err := session.Limit(query.Limit, query.Offset).Count(cmt) return total, err }