OSDN Git Service

Enable to filter graph by ref
authorSato Hiroyuki <sathiroyuki@gmail.com>
Fri, 12 Apr 2013 08:49:11 +0000 (17:49 +0900)
committerSato Hiroyuki <sathiroyuki@gmail.com>
Mon, 13 May 2013 09:44:50 +0000 (18:44 +0900)
app/controllers/graph_controller.rb
app/models/network/graph.rb

index 22544ad..c79ed5c 100644 (file)
@@ -16,7 +16,7 @@ class GraphController < ProjectResourceController
       format.html
 
       format.json do
-        @graph = Network::Graph.new(project, @ref, @commit)
+        @graph = Network::Graph.new(project, @ref, @commit, @options[:filter_ref])
       end
     end
   end
index 2707283..ffec471 100644 (file)
@@ -8,10 +8,11 @@ module Network
       @max_count ||= 650
     end
 
-    def initialize project, ref, commit
+    def initialize project, ref, commit, filter_ref
       @project = project
       @ref = ref
       @commit = commit
+      @filter_ref = filter_ref
       @repo = project.repo
 
       @commits = collect_commits
@@ -107,7 +108,9 @@ module Network
         skip: skip
       }
 
-      Grit::Commit.find_all(@repo, nil, opts)
+      ref = @ref if @filter_ref
+
+      Grit::Commit.find_all(@repo, ref, opts)
     end
 
     def commits_sort_by_ref