summaryrefslogtreecommitdiffstats
path: root/modules/context/repo.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/context/repo.go')
-rw-r--r--modules/context/repo.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go
index f34b05d1d0..0ef644b522 100644
--- a/modules/context/repo.go
+++ b/modules/context/repo.go
@@ -171,6 +171,18 @@ func (r *Repository) GetCommitsCount() (int64, error) {
})
}
+// GetCommitGraphsCount returns cached commit count for current view
+func (r *Repository) GetCommitGraphsCount(hidePRRefs bool, branches []string, files []string) (int64, error) {
+ cacheKey := fmt.Sprintf("commits-count-%d-graph-%t-%s-%s", r.Repository.ID, hidePRRefs, branches, files)
+
+ return cache.GetInt64(cacheKey, func() (int64, error) {
+ if len(branches) == 0 {
+ return git.AllCommitsCount(r.Repository.RepoPath(), hidePRRefs, files...)
+ }
+ return git.CommitsCountFiles(r.Repository.RepoPath(), branches, files)
+ })
+}
+
// BranchNameSubURL sub-URL for the BranchName field
func (r *Repository) BranchNameSubURL() string {
switch {