Commit 784aa266bdd38ec560c11bea92fc9b815e2ca456
1 parent
2f7f46b2
Exists in
master
and in
4 other branches
Refactor: grouping parent and their space by including array.
Showing
3 changed files
with
7 additions
and
5 deletions
Show diff stats
app/assets/javascripts/branch-graph.js
@@ -117,7 +117,7 @@ | @@ -117,7 +117,7 @@ | ||
117 | // Draw lines | 117 | // Draw lines |
118 | for (var j = 0, jj = this.commits[i].parents.length; j < jj; j++) { | 118 | for (var j = 0, jj = this.commits[i].parents.length; j < jj; j++) { |
119 | c = this.preparedCommits[this.commits[i].parents[j][0]]; | 119 | c = this.preparedCommits[this.commits[i].parents[j][0]]; |
120 | - ps = this.commits[i].parent_spaces[j]; | 120 | + ps = this.commits[i].parents[j][1]; |
121 | if (c) { | 121 | if (c) { |
122 | var cx = offsetX + 20 * c.time | 122 | var cx = offsetX + 20 * c.time |
123 | , cy = offsetY + 10 * c.space | 123 | , cy = offsetY + 10 * c.space |
app/helpers/graph_helper.rb
@@ -2,4 +2,9 @@ module GraphHelper | @@ -2,4 +2,9 @@ module GraphHelper | ||
2 | def join_with_space(ary) | 2 | def join_with_space(ary) |
3 | ary.collect{|r|r.name}.join(" ") unless ary.nil? | 3 | ary.collect{|r|r.name}.join(" ") unless ary.nil? |
4 | end | 4 | end |
5 | + | ||
6 | + def parents_zip_spaces(parents, parent_spaces) | ||
7 | + ids = parents.map { |p| p.id } | ||
8 | + ids.zip(parent_spaces) | ||
9 | + end | ||
5 | end | 10 | end |
app/views/graph/show.json.erb
@@ -5,9 +5,7 @@ | @@ -5,9 +5,7 @@ | ||
5 | days: @graph.days.compact.map { |d| [d.day, d.strftime("%b")] }, | 5 | days: @graph.days.compact.map { |d| [d.day, d.strftime("%b")] }, |
6 | commits: @graph.commits.map do |c| | 6 | commits: @graph.commits.map do |c| |
7 | { | 7 | { |
8 | - parents: c.parents.collect do |p| | ||
9 | - [p.id,0,0] | ||
10 | - end, | 8 | + parents: parents_zip_spaces(c.parents, c.parent_spaces), |
11 | author: { | 9 | author: { |
12 | name: c.author.name, | 10 | name: c.author.name, |
13 | email: c.author.email, | 11 | email: c.author.email, |
@@ -15,7 +13,6 @@ | @@ -15,7 +13,6 @@ | ||
15 | }, | 13 | }, |
16 | time: c.time, | 14 | time: c.time, |
17 | space: c.spaces.first, | 15 | space: c.spaces.first, |
18 | - parent_spaces: c.parent_spaces, | ||
19 | refs: join_with_space(c.refs), | 16 | refs: join_with_space(c.refs), |
20 | id: c.sha, | 17 | id: c.sha, |
21 | date: c.date, | 18 | date: c.date, |