summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorjaqra <48099350+jaqra@users.noreply.github.com>2019-10-15 00:38:35 +0300
committerzeripath <art27@cantab.net>2019-10-14 22:38:35 +0100
commit086bfb8b4b655f46ac9471cbea9df70e912c315d (patch)
treef89c2f17afa05b622e644a81ae09c087d83452b3 /models
parent30835226207f9a618bb2d4956fb209b1dbe099e6 (diff)
downloadgitea-086bfb8b4b655f46ac9471cbea9df70e912c315d.tar.gz
gitea-086bfb8b4b655f46ac9471cbea9df70e912c315d.zip
Add pagination to commit graph page (#8360)
Fixes #8308
Diffstat (limited to 'models')
-rw-r--r--models/graph.go3
-rw-r--r--models/graph_test.go2
2 files changed, 3 insertions, 2 deletions
diff --git a/models/graph.go b/models/graph.go
index 5f68abaf74..0efb51b3fc 100644
--- a/models/graph.go
+++ b/models/graph.go
@@ -30,7 +30,7 @@ type GraphItem struct {
type GraphItems []GraphItem
// GetCommitGraph return a list of commit (GraphItems) from all branches
-func GetCommitGraph(r *git.Repository) (GraphItems, error) {
+func GetCommitGraph(r *git.Repository, page int) (GraphItems, error) {
var CommitGraph []GraphItem
@@ -43,6 +43,7 @@ func GetCommitGraph(r *git.Repository) (GraphItems, error) {
"-C",
"-M",
fmt.Sprintf("-n %d", setting.UI.GraphMaxCommitNum),
+ fmt.Sprintf("--skip=%d", setting.UI.GraphMaxCommitNum*(page-1)),
"--date=iso",
fmt.Sprintf("--pretty=format:%s", format),
)
diff --git a/models/graph_test.go b/models/graph_test.go
index 5c78e3877b..c1f0bc90d9 100644
--- a/models/graph_test.go
+++ b/models/graph_test.go
@@ -19,7 +19,7 @@ func BenchmarkGetCommitGraph(b *testing.B) {
}
for i := 0; i < b.N; i++ {
- graph, err := GetCommitGraph(currentRepo)
+ graph, err := GetCommitGraph(currentRepo, 1)
if err != nil {
b.Error("Could get commit graph")
}