diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index f5fa007a5..717007f54 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -459,6 +459,12 @@ 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_commits_six_month" + data = author_commits_six_month(@repository) + when "author_qoc_per_author" + data = graph_author_qoc_per_author(@repository) end if data headers["Content-Type"] = "image/svg+xml" @@ -617,6 +623,80 @@ update ) graph.burn end + + # 用户每月提交次数 + def graph_author_commits_per_month(repository) + @date_to = Date.today + @date_from = @date_to << 1 + @date_from = Date.civil(@date_from.year, @date_from.month, @date_from.day) + commits_by_author = Changeset.count(:all, :group => :committer, + :conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to]) + commits_by_author = commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}.last(40) + + fields = commits_by_author.collect {|r| r.first} + commits_data = commits_by_author.collect {|r| r.last} + + fields = fields + [""]*(10 - fields.length) if fields.length<10 + commits_data = commits_data + [0]*(10 - commits_data.length) if commits_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.burn + end + + # 用户最近六个月的提交次数 + def author_commits_six_month(repository) + @date_to = Date.today + @date_from = @date_to << 6 + @date_from = Date.civil(@date_from.year, @date_from.month, @date_from.day) + commits_by_author = Changeset.count(:all, :group => :committer, + :conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to]) + commits_by_author = commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}.last(40) + + fields = commits_by_author.collect {|r| r.first} + commits_data = commits_by_author.collect {|r| r.last} + + fields = fields + [""]*(10 - fields.length) if fields.length<10 + commits_data = commits_data + [0]*(10 - commits_data.length) if commits_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_six_month), + :show_graph_title => true + ) + graph.add_data( + :data => commits_data, + :title => l(:label_revision_plural) + ) + graph.burn + end + + def check_hidden_repo project = Project.find(params[:id]) if !User.current.member_of?(project) diff --git a/app/views/projects/yun_dep.html.erb b/app/views/projects/yun_dep.html.erb index 20abf038f..7a774f4e4 100644 --- a/app/views/projects/yun_dep.html.erb +++ b/app/views/projects/yun_dep.html.erb @@ -5,27 +5,27 @@
-

云化部署中...

-
-
0%
+

云化部署中....

+
+