Commit 784aa266bdd38ec560c11bea92fc9b815e2ca456

Authored by Sato Hiroyuki
1 parent 2f7f46b2

Refactor: grouping parent and their space by including array.

app/assets/javascripts/branch-graph.js
... ... @@ -117,7 +117,7 @@
117 117 // Draw lines
118 118 for (var j = 0, jj = this.commits[i].parents.length; j < jj; j++) {
119 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 121 if (c) {
122 122 var cx = offsetX + 20 * c.time
123 123 , cy = offsetY + 10 * c.space
... ...
app/helpers/graph_helper.rb
... ... @@ -2,4 +2,9 @@ module GraphHelper
2 2 def join_with_space(ary)
3 3 ary.collect{|r|r.name}.join(" ") unless ary.nil?
4 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 10 end
... ...
app/views/graph/show.json.erb
... ... @@ -5,9 +5,7 @@
5 5 days: @graph.days.compact.map { |d| [d.day, d.strftime("%b")] },
6 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 9 author: {
12 10 name: c.author.name,
13 11 email: c.author.email,
... ... @@ -15,7 +13,6 @@
15 13 },
16 14 time: c.time,
17 15 space: c.spaces.first,
18   - parent_spaces: c.parent_spaces,
19 16 refs: join_with_space(c.refs),
20 17 id: c.sha,
21 18 date: c.date,
... ...