版本库:最近一月的提交次数统计
This commit is contained in:
parent
6911debad0
commit
a2c2f41908
|
@ -459,6 +459,10 @@ update
|
|||
data = graph_commits_per_month(@repository)
|
||||
when "commits_per_author"
|
||||
data = graph_commits_per_author(@repository)
|
||||
when "author_commits_per_month"
|
||||
data = graph_author_commits_per_month(@repository)
|
||||
when "author_qoc_per_author"
|
||||
data = graph_author_qoc_per_author(@repository)
|
||||
end
|
||||
if data
|
||||
headers["Content-Type"] = "image/svg+xml"
|
||||
|
@ -536,12 +540,15 @@ update
|
|||
def graph_commits_per_month(repository)
|
||||
@date_to = Date.today
|
||||
@date_from = @date_to << 11
|
||||
@date_from = Date.civil(@date_from.year, @date_from.month, 1)
|
||||
@date_from = Date.civil(@date_from.year, @date_from.month, 1) ## Date.new(2001,2,-1) #=> #<Date: 2001-02-28 ...>
|
||||
# commits_by_day[0] 为data 【2】为count
|
||||
commits_by_day = Changeset.count(
|
||||
:all, :group => :commit_date,
|
||||
:conditions => ["repository_id = ? AND commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to])
|
||||
commits_by_month = [0] * 12
|
||||
commits_by_day.each {|c| commits_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last }
|
||||
commits_by_day.each do |c|
|
||||
commits_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last
|
||||
end
|
||||
|
||||
changes_by_day = Change.count(
|
||||
:all, :group => :commit_date, :include => :changeset,
|
||||
|
@ -617,6 +624,52 @@ update
|
|||
)
|
||||
graph.burn
|
||||
end
|
||||
|
||||
# 用户每月提交次数
|
||||
def graph_author_commits_per_month(repository)
|
||||
commits_by_author = Changeset.count(:all, :group => :committer, :conditions => ["repository_id = ?", repository.id])
|
||||
commits_by_author = commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}.last(25)
|
||||
|
||||
changes_by_author = Change.count(:all, :group => :committer, :include => :changeset, :conditions => ["#{Changeset.table_name}.repository_id = ?", repository.id])
|
||||
h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o}
|
||||
|
||||
fields = commits_by_author.collect {|r| r.first}
|
||||
commits_data = commits_by_author.collect {|r| r.last}
|
||||
changes_data = commits_by_author.collect {|r| h[r.first] || 0}
|
||||
|
||||
fields = fields + [""]*(10 - fields.length) if fields.length<10
|
||||
commits_data = commits_data + [0]*(10 - commits_data.length) if commits_data.length<10
|
||||
changes_data = changes_data + [0]*(10 - changes_data.length) if changes_data.length<10
|
||||
|
||||
# Remove email adress in usernames
|
||||
fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') }
|
||||
|
||||
graph = SVG::Graph::BarHorizontal.new(
|
||||
:height => 400,
|
||||
:width => 600,
|
||||
:fields => fields,
|
||||
:stack => :side,
|
||||
:scale_integers => true,
|
||||
:show_data_values => true,
|
||||
:rotate_y_labels => false,
|
||||
:graph_title => l(:label_author_commits_per_month),
|
||||
:show_graph_title => true
|
||||
)
|
||||
graph.add_data(
|
||||
:data => commits_data,
|
||||
:title => l(:label_revision_plural)
|
||||
)
|
||||
# graph.add_data(
|
||||
# :data => changes_data,
|
||||
# :title => l(:label_change_plural)
|
||||
# )
|
||||
graph.burn
|
||||
end
|
||||
|
||||
def graph_author_qoc_per_author(repository)
|
||||
|
||||
end
|
||||
|
||||
def check_hidden_repo
|
||||
project = Project.find(params[:id])
|
||||
if !User.current.member_of?(project)
|
||||
|
|
|
@ -7,7 +7,15 @@
|
|||
<%= tag("embed", :width => 670, :height => 300, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "commits_per_month")) %>
|
||||
</p>
|
||||
<p style="padding-top: 50px;">
|
||||
<%# 用户每月提交代码次数 %>
|
||||
<%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "commits_per_author")) %>
|
||||
</p>
|
||||
<p style="padding-top: 50px;">
|
||||
<%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "author_commits_per_month")) %>
|
||||
</p>
|
||||
<p style="padding-top: 50px;">
|
||||
<%# 用户每月提交代码量 %>
|
||||
<%= tag("embed", :width => 670, :height => 400, :type => "image/svg+xml", :src => url_for(:controller => 'repositories', :action => 'graph', :id => @project, :repository_id => @repository.identifier_param, :graph => "author_qoc_per_author")) %>
|
||||
</p>
|
||||
<p><%= link_to l(:button_back), :action => 'show', :id => @project %></p>
|
||||
<% html_title(l(:label_repository), l(:label_statistics)) -%>
|
||||
|
|
|
@ -715,6 +715,7 @@ zh:
|
|||
|
||||
label_commits_per_month: 每月提交次数
|
||||
label_commits_per_author: 每用户提交次数
|
||||
label_author_commits_per_month: 用户最近一月的提交次数
|
||||
label_view_diff: 查看差别
|
||||
label_diff_inline: 直列
|
||||
label_diff_side_by_side: 并排
|
||||
|
|
Loading…
Reference in New Issue