Defect #1983 » quick_hack.patch
| app/controllers/repositories_controller.rb | ||
|---|---|---|
|
when "commits_per_author"
|
||
|
data = graph_commits_per_author(@repository)
|
||
|
end
|
||
|
if data
|
||
|
if data[:graph_data]
|
||
|
headers["Content-Type"] = "image/svg+xml"
|
||
|
send_data(data, :type => "image/svg+xml", :disposition => "inline")
|
||
|
params[:height] = data[:graph_height]
|
||
|
send_data(data[:graph_data], :type => "image/svg+xml", :disposition => "inline")
|
||
|
else
|
||
|
render_404
|
||
|
end
|
||
| ... | ... | |
|
fields = []
|
||
|
month_names = l(:actionview_datehelper_select_month_names_abbr).split(',')
|
||
|
12.times {|m| fields << month_names[((Date.today.month - 1 - m) % 12)]}
|
||
|
#doing this for consistency with the commits_per_author
|
||
|
graph_height = 300
|
||
|
|
||
|
graph = SVG::Graph::Bar.new(
|
||
|
:height => 300,
|
||
|
:height => graph_height,
|
||
|
:width => 800,
|
||
|
:fields => fields.reverse,
|
||
|
:stack => :side,
|
||
| ... | ... | |
|
:title => l(:label_change_plural)
|
||
|
)
|
||
|
|
||
|
graph.burn
|
||
|
# hack to get graph height back easily
|
||
|
hack_hash = {}
|
||
|
hack_hash[:graph_data] = graph.burn
|
||
|
hack_hash[:graph_height] =graph_height
|
||
|
hack_hash
|
||
|
end
|
||
|
def graph_commits_per_author(repository)
|
||
| ... | ... | |
|
|
||
|
# Remove email adress in usernames
|
||
|
fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') }
|
||
|
# deal with a large amount of users
|
||
|
if fields.length > 10 then
|
||
|
graph_height = fields.length * 15
|
||
|
else
|
||
|
graph_height = 400
|
||
|
end
|
||
|
|
||
|
graph = SVG::Graph::BarHorizontal.new(
|
||
|
:height => 400,
|
||
|
:height => graph_height,
|
||
|
:width => 800,
|
||
|
:fields => fields,
|
||
|
:stack => :side,
|
||
| ... | ... | |
|
:title => l(:label_change_plural)
|
||
|
)
|
||
|
|
||
|
graph.burn
|
||
|
# hack to get graph height back easily
|
||
|
hack_hash = {}
|
||
|
hack_hash[:graph_data] = graph.burn
|
||
|
hack_hash[:graph_height] =graph_height
|
||
|
hack_hash
|
||
|
end
|
||
|
end
|
||
| app/views/repositories/stats.rhtml | ||
|---|---|---|
|
<h2><%= l(:label_statistics) %></h2>
|
||
|
|
||
|
<p>
|
||
|
<%= tag("embed", :width => 800, :height => 300, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :graph => "commits_per_month")) %>
|
||
|
<%= tag("embed", :width => 800, :height => params[:height], :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :graph => "commits_per_month")) %>
|
||
|
</p>
|
||
|
<p>
|
||
|
<%= tag("embed", :width => 800, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :graph => "commits_per_author")) %>
|
||
|
<%= tag("embed", :width => 800, :height => params[:height], :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :graph => "commits_per_author")) %>
|
||
|
</p>
|
||
|
|
||
|
<p><%= link_to l(:button_back), :action => 'show', :id => @project %></p>
|
||