diff options
author | Unknwon <u@gogs.io> | 2015-09-04 05:54:22 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-09-04 05:54:22 -0400 |
commit | d023e81a8f6016db0bdaf8a935f273cc6e0d9a49 (patch) | |
tree | 669879e2a6631434df0ff1ca15fa64dd9a6a69ea /models/repo.go | |
parent | 36a69e8aa5a3bd35396173b4f108b33c19e6ac88 (diff) | |
download | gitea-d023e81a8f6016db0bdaf8a935f273cc6e0d9a49.tar.gz gitea-d023e81a8f6016db0bdaf8a935f273cc6e0d9a49.zip |
#1577 explore paginator problem
Diffstat (limited to 'models/repo.go')
-rw-r--r-- | models/repo.go | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/models/repo.go b/models/repo.go index 346eb64736..9fb5607db7 100644 --- a/models/repo.go +++ b/models/repo.go @@ -740,10 +740,25 @@ func CreateRepository(u *User, opts CreateRepoOptions) (_ *Repository, err error return repo, sess.Commit() } +func countRepositories(showPrivate bool) int64 { + sess := x.NewSession() + + if !showPrivate { + sess.Where("is_private=", false) + } + + count, _ := sess.Count(new(Repository)) + return count +} + // CountRepositories returns number of repositories. func CountRepositories() int64 { - count, _ := x.Count(new(Repository)) - return count + return countRepositories(true) +} + +// CountPublicRepositories returns number of public repositories. +func CountPublicRepositories() int64 { + return countRepositories(false) } // GetRepositoriesWithUsers returns given number of repository objects with offset. |