Commit, network graph refactoring
This commit is contained in:
parent
1b2fba08fe
commit
a031813887
14 changed files with 125 additions and 97 deletions
|
@ -86,31 +86,7 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def graph
|
||||
@repo = project.repo
|
||||
commits = Grit::Commit.find_all(@repo, nil, {:max_count => 650})
|
||||
ref_cache = {}
|
||||
commits.collect! do |commit|
|
||||
add_refs(commit, ref_cache)
|
||||
GraphCommit.new(commit)
|
||||
end
|
||||
|
||||
days = GraphCommit.index_commits(commits)
|
||||
@days_json = days.compact.collect{|d| [d.day, d.strftime("%b")] }.to_json
|
||||
@commits_json = commits.collect do |c|
|
||||
h = {}
|
||||
h[:parents] = c.parents.collect do |p|
|
||||
[p.id,0,0]
|
||||
end
|
||||
h[:author] = c.author.name.force_encoding("UTF-8")
|
||||
h[:time] = c.time
|
||||
h[:space] = c.space
|
||||
h[:refs] = c.refs.collect{|r|r.name}.join(" ") unless c.refs.nil?
|
||||
h[:id] = c.sha
|
||||
h[:date] = c.date
|
||||
h[:message] = c.message.force_encoding("UTF-8")
|
||||
h[:login] = c.author.email
|
||||
h
|
||||
end.to_json
|
||||
@days_json, @commits_json = GraphCommit.to_graph(project)
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
@ -123,17 +99,6 @@ class ProjectsController < ApplicationController
|
|||
|
||||
protected
|
||||
|
||||
def add_refs(commit, ref_cache)
|
||||
if ref_cache.empty?
|
||||
@repo.refs.each do |ref|
|
||||
ref_cache[ref.commit.id] ||= []
|
||||
ref_cache[ref.commit.id] << ref
|
||||
end
|
||||
end
|
||||
commit.refs = ref_cache[commit.id] if ref_cache.include? commit.id
|
||||
commit.refs ||= []
|
||||
end
|
||||
|
||||
def project
|
||||
@project ||= Project.find_by_code(params[:id])
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue