Commit 46fa92187d6c076619e9cd58877e03c6d15a1f03
1 parent
7587a3b2
Exists in
master
and in
4 other branches
Refactor: removing duplicate code.
Showing
1 changed file
with
14 additions
and
10 deletions
Show diff stats
app/models/network/graph.rb
@@ -25,15 +25,7 @@ module Network | @@ -25,15 +25,7 @@ module Network | ||
25 | def collect_commits | 25 | def collect_commits |
26 | refs_cache = build_refs_cache | 26 | refs_cache = build_refs_cache |
27 | 27 | ||
28 | - Grit::Commit.find_all( | ||
29 | - @repo, | ||
30 | - nil, | ||
31 | - { | ||
32 | - date_order: true, | ||
33 | - max_count: self.class.max_count, | ||
34 | - skip: count_to_display_commit_in_center | ||
35 | - } | ||
36 | - ) | 28 | + find_commits(count_to_display_commit_in_center) |
37 | .map do |commit| | 29 | .map do |commit| |
38 | # Decorate with app/model/network/commit.rb | 30 | # Decorate with app/model/network/commit.rb |
39 | Network::Commit.new(commit, refs_cache[commit.id]) | 31 | Network::Commit.new(commit, refs_cache[commit.id]) |
@@ -74,7 +66,7 @@ module Network | @@ -74,7 +66,7 @@ module Network | ||
74 | 66 | ||
75 | # Skip count that the target commit is displayed in center. | 67 | # Skip count that the target commit is displayed in center. |
76 | def count_to_display_commit_in_center | 68 | def count_to_display_commit_in_center |
77 | - commit_index = Grit::Commit.find_all(@repo, nil, {date_order: true}).index do |c| | 69 | + commit_index = find_commits.index do |c| |
78 | c.id == @commit.id | 70 | c.id == @commit.id |
79 | end | 71 | end |
80 | 72 | ||
@@ -86,6 +78,18 @@ module Network | @@ -86,6 +78,18 @@ module Network | ||
86 | end | 78 | end |
87 | end | 79 | end |
88 | 80 | ||
81 | + def find_commits(skip = 0) | ||
82 | + Grit::Commit.find_all( | ||
83 | + @repo, | ||
84 | + nil, | ||
85 | + { | ||
86 | + date_order: true, | ||
87 | + max_count: self.class.max_count, | ||
88 | + skip: skip | ||
89 | + } | ||
90 | + ) | ||
91 | + end | ||
92 | + | ||
89 | def commits_sort_by_ref | 93 | def commits_sort_by_ref |
90 | @commits.sort do |a,b| | 94 | @commits.sort do |a,b| |
91 | if include_ref?(a) | 95 | if include_ref?(a) |