summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSato Hiroyuki <sathiroyuki@gmail.com>2013-03-06 21:01:40 +0900
committerSato Hiroyuki <sathiroyuki@gmail.com>2013-03-07 15:19:42 +0900
commit784aa266bdd38ec560c11bea92fc9b815e2ca456 (patch)
tree7a2d933fdc7694bb6dbaf973992fd4abb32cc1df
parent2f7f46b25655aa6f2c2a7756663c97ddb4491100 (diff)
downloadgitlab-ce-784aa266bdd38ec560c11bea92fc9b815e2ca456.tar.gz
Refactor: grouping parent and their space by including array.
-rw-r--r--app/assets/javascripts/branch-graph.js2
-rw-r--r--app/helpers/graph_helper.rb5
-rw-r--r--app/views/graph/show.json.erb5
3 files changed, 7 insertions, 5 deletions
diff --git a/app/assets/javascripts/branch-graph.js b/app/assets/javascripts/branch-graph.js
index 137e87de37f..520336adc0f 100644
--- a/app/assets/javascripts/branch-graph.js
+++ b/app/assets/javascripts/branch-graph.js
@@ -117,7 +117,7 @@
// Draw lines
for (var j = 0, jj = this.commits[i].parents.length; j < jj; j++) {
c = this.preparedCommits[this.commits[i].parents[j][0]];
- ps = this.commits[i].parent_spaces[j];
+ ps = this.commits[i].parents[j][1];
if (c) {
var cx = offsetX + 20 * c.time
, cy = offsetY + 10 * c.space
diff --git a/app/helpers/graph_helper.rb b/app/helpers/graph_helper.rb
index ba8c68a1ce0..369330151f4 100644
--- a/app/helpers/graph_helper.rb
+++ b/app/helpers/graph_helper.rb
@@ -2,4 +2,9 @@ module GraphHelper
def join_with_space(ary)
ary.collect{|r|r.name}.join(" ") unless ary.nil?
end
+
+ def parents_zip_spaces(parents, parent_spaces)
+ ids = parents.map { |p| p.id }
+ ids.zip(parent_spaces)
+ end
end
diff --git a/app/views/graph/show.json.erb b/app/views/graph/show.json.erb
index 0531bc3c920..4a8605eec55 100644
--- a/app/views/graph/show.json.erb
+++ b/app/views/graph/show.json.erb
@@ -5,9 +5,7 @@
days: @graph.days.compact.map { |d| [d.day, d.strftime("%b")] },
commits: @graph.commits.map do |c|
{
- parents: c.parents.collect do |p|
- [p.id,0,0]
- end,
+ parents: parents_zip_spaces(c.parents, c.parent_spaces),
author: {
name: c.author.name,
email: c.author.email,
@@ -15,7 +13,6 @@
},
time: c.time,
space: c.spaces.first,
- parent_spaces: c.parent_spaces,
refs: join_with_space(c.refs),
id: c.sha,
date: c.date,