From 6b3882aff8853902a994b40730743fb10f252bfb Mon Sep 17 00:00:00 2001
From: zhangshenjerry <1375181337@qq.com>
Date: Fri, 24 Jul 2015 16:33:53 +0800
Subject: [PATCH 01/21] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?=
=?UTF-8?q?=EF=BC=9A=E5=A6=82=E5=9B=BE=E5=80=BC=E4=B8=BA0=E6=97=B6?=
=?UTF-8?q?=EF=BC=8C=E8=BF=99=E4=BA=9B=E5=AD=97=E6=AE=B5=E4=B8=8D=E8=A6=81?=
=?UTF-8?q?=E6=98=BE=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/layouts/base_users_new.html.erb | 72 +++++++++++++++++------
app/views/my/account.html.erb | 1 -
2 files changed, 54 insertions(+), 19 deletions(-)
diff --git a/app/views/layouts/base_users_new.html.erb b/app/views/layouts/base_users_new.html.erb
index bbfe9a1ea..4b6bd2887 100644
--- a/app/views/layouts/base_users_new.html.erb
+++ b/app/views/layouts/base_users_new.html.erb
@@ -149,29 +149,65 @@
<% if !@user.user_extensions.nil? && @user.user_extensions.identity == 0 %>
- - 创建课程 :
- - 发布作业 :
+ <% if(get_create_course_count(@user)) == 0 %>
+ - 创建课程 :
+ <% end %>
+ <% if(get_homework_commons_count(@user)) == 0 %>
+ - 发布作业 :
+ <% end %>
+ <% end %>
+ <% if (get_join_course_count(@user) != 0) %>
+ - 加入课程 :
+ <% end %>
+ <% if @user.user_extensions.identity == 0 %>
+ - 参加匿评 :
+ <% end %>
+ <% if (get_projectandcourse_attachment_count(@user) != 0) %>
+ - 发布资源 :
+ <% end %>
+ <% if (get_create_project_count(@user) != 0) %>
+ - 创建项目 :
+ <% end %>
+ <% if (get_join_project_count(@user) != 0) %>
+ - 加入项目 :
+ <% end %>
+ <% if (get_create_issue_count(@user) != 0) %>
+ - 发布缺陷 :
+ <% end %>
+ <% if (get_resolve_issue_count(@user) != 0) %>
+ - 解决缺陷 :
<% end %>
- - 加入课程 :
- - 参加匿评 :
- - 发布资源 :
- - 创建项目 :
- - 加入项目 :
- - 发布缺陷 :
- - 解决缺陷 :
<% if !@user.user_extensions.nil? && @user.user_extensions.identity == 0 %>
- - <%= get_create_course_count(@user) %>
- - <%= get_homework_commons_count(@user) %>
+ <% if(get_create_course_count(@user)) == 0 %>
+ - <%= get_create_course_count(@user) %>
+ <% end %>
+ <% if(get_homework_commons_count(@user)) == 0 %>
+ - <%= get_homework_commons_count(@user) %>
+ <% end %>
+ <% end %>
+ <% if (get_join_course_count(@user) != 0) %>
+ - <%= get_join_course_count(@user) %>
+ <% end %>
+ <% if @user.user_extensions.identity == 0 %>
+ - <%= get_anonymous_evaluation_count(@user) %>
+ <% end %>
+ <% if (get_projectandcourse_attachment_count(@user) != 0) %>
+ - <%= get_projectandcourse_attachment_count(@user) %>
+ <% end %>
+ <% if (get_create_project_count(@user) != 0) %>
+ - <%= get_create_project_count(@user) %>
+ <% end %>
+ <% if (get_join_project_count(@user) != 0) %>
+ - <%= get_join_project_count(@user) %>
+ <% end %>
+ <% if (get_create_issue_count(@user) != 0) %>
+ - <%= get_create_issue_count(@user) %>
+ <% end %>
+ <% if (get_resolve_issue_count(@user) != 0) %>
+ - <%= get_resolve_issue_count(@user) %>
<% end %>
- - <%= get_join_course_count(@user) %>
- - <%= get_anonymous_evaluation_count(@user) %>
- - <%= get_projectandcourse_attachment_count(@user) %>
- - <%= get_create_project_count(@user) %>
- - <%= get_join_project_count(@user) %>
- - <%= get_create_issue_count(@user) %>
- - <%= get_resolve_issue_count(@user) %>
diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb
index 57c3712f9..c23266afd 100644
--- a/app/views/my/account.html.erb
+++ b/app/views/my/account.html.erb
@@ -540,7 +540,6 @@
$('#my_account_form_btn').click();
});
$('#my_password_form_link').click(function(){
- alert("密码修改成功,请重新登录!");
$('#my_password_form_btn').click();
});
});
From 71970e1942f2b00f43ed92af4e7d65a113608359 Mon Sep 17 00:00:00 2001
From: guange <8863824@gmail.com>
Date: Fri, 24 Jul 2015 16:53:21 +0800
Subject: [PATCH 02/21] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=8C=89=E6=97=B6?=
=?UTF-8?q?=E9=97=B4=E6=AE=B5=E6=9D=A5=E7=BB=9F=E8=AE=A1=E6=AF=8F=E4=BA=BA?=
=?UTF-8?q?=E7=9A=84=E6=8F=90=E4=BA=A4=E9=87=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/repository/git.rb | 4 ++++
lib/redmine/scm/adapters/git_adapter.rb | 29 +++++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/app/models/repository/git.rb b/app/models/repository/git.rb
index c1f0020eb..f3ea8e003 100644
--- a/app/models/repository/git.rb
+++ b/app/models/repository/git.rb
@@ -38,6 +38,10 @@ class Repository::Git < Repository
'Git'
end
+ def commits(authors, start_date, end_date)
+ scm.commits(authors, start_date, end_date)
+ end
+
def report_last_commit
extra_report_last_commit
end
diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb
index 1876190d9..81c361f6e 100644
--- a/lib/redmine/scm/adapters/git_adapter.rb
+++ b/lib/redmine/scm/adapters/git_adapter.rb
@@ -380,6 +380,35 @@ module Redmine
nil
end
+ def parse_commit(commits)
+ sum = {file: 0, insertion: 0, deletion: 0}
+ commits.split("\n").each do |commit|
+ if /(\d+)\s+?file/ =~ commit
+ sum[:file] += $1 .to_i
+ end
+ if /(\d+)\s+?insertion/ =~ commit
+ sum[:insertion] += $1.to_i
+ end
+ if /(\d+)\s+?deletion/ =~ commit
+ sum[:deletion] += $1.to_i
+ end
+ end
+ sum[:insertion] + sum[:deletion]
+ end
+
+ def commits(authors, start_date, end_date)
+ rs = []
+ authors.each do |author|
+ cmd_args = %W|log --pretty=tformat: --shortstat --author=#{author} --since=#{start_date} --until=#{end_date}|
+ commits = ''
+ git_cmd(cmd_args) do |io|
+ commits = io.read
+ end
+ rs << {author: author, num: parse_commit(commits)}
+ end
+ rs
+ end
+
class Revision < Redmine::Scm::Adapters::Revision
# Returns the readable identifier
def format_identifier
From 69b9cbee80125e0c1043a87d036f69caa5cc4d3e Mon Sep 17 00:00:00 2001
From: huang
Date: Fri, 24 Jul 2015 16:56:37 +0800
Subject: [PATCH 03/21] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E4=BB=A3?=
=?UTF-8?q?=E7=A0=81=E7=BB=9F=E8=AE=A1=EF=BC=88=E6=9C=AA=E5=AE=8C=E6=88=90?=
=?UTF-8?q?=EF=BC=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/repositories/stats.html.erb | 8 ++++++++
config/locales/zh.yml | 4 +++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/app/views/repositories/stats.html.erb b/app/views/repositories/stats.html.erb
index ebb670438..ba14e18b1 100644
--- a/app/views/repositories/stats.html.erb
+++ b/app/views/repositories/stats.html.erb
@@ -25,5 +25,13 @@
<%# 用户最近一年的提交次数 %>
<%= 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")) %>
+
+ <%# 用户最近六个月的代码量 %>
+ <%= 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_code_six_months")) %>
+
+
+ <%# 用户最近一年的代码量 %>
+ <%= 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_code_year")) %>
+
<%= link_to l(:button_back), :action => 'show', :id => @project %>
<% html_title(l(:label_repository), l(:label_statistics)) -%>
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index 9b3254bb2..a5f4f4d10 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -716,8 +716,10 @@ zh:
label_commits_per_month: 每月提交次数
label_commits_per_author: 每用户提交次数
label_author_commits_per_month: 用户最近一月的提交次数
- label_author_commits_six_month: 用户最近六个月的提交次数
+ label_author_commits_six_month: 用户最近六个月提交次数
label_author_commits_year: 最近一年的提交次数
+ label_author_code_six_month: 用户最近六个月代码量
+ label_author_code_year: 用户最近一年代码量
label_view_diff: 查看差别
label_diff_inline: 直列
label_diff_side_by_side: 并排
From ea93a68a84137bbc3787922130c411cfcfbf3848 Mon Sep 17 00:00:00 2001
From: huang
Date: Fri, 24 Jul 2015 17:40:43 +0800
Subject: [PATCH 04/21] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=EF=BC=9A?=
=?UTF-8?q?=E7=94=A8=E6=88=B7=E5=85=AD=E4=B8=AA=E6=9C=88=E4=BB=A3=E7=A0=81?=
=?UTF-8?q?=E9=87=8F=E7=BB=9F=E8=AE=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/repositories_controller.rb | 43 ++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 717007f54..fc05b082d 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -465,6 +465,8 @@ update
data = author_commits_six_month(@repository)
when "author_qoc_per_author"
data = graph_author_qoc_per_author(@repository)
+ when "author_code_six_months"
+ data = author_code_six_month(@repository)
end
if data
headers["Content-Type"] = "image/svg+xml"
@@ -696,6 +698,47 @@ update
graph.burn
end
+ # 最近六个月代码量统计
+ def author_code_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(: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)
+ all_author = []
+ commits_by_author.each do |cba|
+ all_author << cba.first
+ end
+ all_author = all_author.collect {|c| c.gsub(%r{<.+@.+>}, '') }
+ commits_by_author = repository.commits(all_author, @date_from, @date_to)
+
+ 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])
From 0a300724d318a339c433c39225674b48bd6de35d Mon Sep 17 00:00:00 2001
From: guange <8863824@gmail.com>
Date: Fri, 24 Jul 2015 22:54:42 +0800
Subject: [PATCH 05/21] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E7=BB=93=E6=9E=9C?=
=?UTF-8?q?=E6=94=B9=E4=B8=BA=E6=95=B0=E7=BB=84=E8=BF=94=E5=9B=9E?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/repository/git.rb | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/models/repository/git.rb b/app/models/repository/git.rb
index f3ea8e003..041175572 100644
--- a/app/models/repository/git.rb
+++ b/app/models/repository/git.rb
@@ -39,7 +39,9 @@ class Repository::Git < Repository
end
def commits(authors, start_date, end_date)
- scm.commits(authors, start_date, end_date)
+ scm.commits(authors, start_date, end_date).map {|commit|
+ [commit[:author], commit[:num]]
+ }
end
def report_last_commit
From b9a902bb041baaafcd926c6aa6adf26e055526e7 Mon Sep 17 00:00:00 2001
From: huang
Date: Fri, 24 Jul 2015 23:09:28 +0800
Subject: [PATCH 06/21] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=BB=9F=E8=AE=A1?=
=?UTF-8?q?=E6=A0=87=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/repositories_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index fc05b082d..ada42e1f2 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -729,7 +729,7 @@ update
:scale_integers => true,
:show_data_values => true,
:rotate_y_labels => false,
- :graph_title => l(:label_author_commits_six_month),
+ :graph_title => l(:label_author_code_six_month),
:show_graph_title => true
)
graph.add_data(
From 0a1afd7c450cb80dbd77ef9bd4968a234b5589c3 Mon Sep 17 00:00:00 2001
From: huang
Date: Fri, 24 Jul 2015 23:25:56 +0800
Subject: [PATCH 07/21] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=89=93=E5=8D=B0?=
=?UTF-8?q?=E7=BB=93=E6=9E=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/repositories_controller.rb | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index ada42e1f2..bc3c0af02 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -711,6 +711,8 @@ update
end
all_author = all_author.collect {|c| c.gsub(%r{<.+@.+>}, '') }
commits_by_author = repository.commits(all_author, @date_from, @date_to)
+ logger.info "start******************************************************************" + commits_by_author
+ logger.info "end**************************************************************8"
fields = commits_by_author.collect {|r| r.first}
commits_data = commits_by_author.collect {|r| r.last}
@@ -719,7 +721,7 @@ update
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{<.+@.+>}, '') }
+ # fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') }
graph = SVG::Graph::BarHorizontal.new(
:height => 400,
From 6aa332d1f66fda984da852a7ce54d9ca5222c27e Mon Sep 17 00:00:00 2001
From: huang
Date: Fri, 24 Jul 2015 23:36:24 +0800
Subject: [PATCH 08/21] =?UTF-8?q?=E8=B0=83=E8=AF=95=E3=80=81=E6=89=93?=
=?UTF-8?q?=E5=8D=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/repositories_controller.rb | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index bc3c0af02..d15b581f6 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -711,8 +711,7 @@ update
end
all_author = all_author.collect {|c| c.gsub(%r{<.+@.+>}, '') }
commits_by_author = repository.commits(all_author, @date_from, @date_to)
- logger.info "start******************************************************************" + commits_by_author
- logger.info "end**************************************************************8"
+ Rails.logger.debug "######################################{commits_by_author}"
fields = commits_by_author.collect {|r| r.first}
commits_data = commits_by_author.collect {|r| r.last}
@@ -721,7 +720,7 @@ update
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{<.+@.+>}, '') }
+ fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') }
graph = SVG::Graph::BarHorizontal.new(
:height => 400,
From c339e9071bf91752cc2ead3dcaa07956830abf00 Mon Sep 17 00:00:00 2001
From: huang
Date: Fri, 24 Jul 2015 23:55:13 +0800
Subject: [PATCH 09/21] =?UTF-8?q?date=E7=B1=BB=E5=9E=8B=E8=BD=AC=E6=8D=A2?=
=?UTF-8?q?=E6=88=90string=E7=B1=BB=E5=9E=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/repositories_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index d15b581f6..03ab9d2e3 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -710,7 +710,7 @@ update
all_author << cba.first
end
all_author = all_author.collect {|c| c.gsub(%r{<.+@.+>}, '') }
- commits_by_author = repository.commits(all_author, @date_from, @date_to)
+ commits_by_author = repository.commits(all_author, "#{@date_from}", "#{@date_to}")
Rails.logger.debug "######################################{commits_by_author}"
fields = commits_by_author.collect {|r| r.first}
From 088e9b200a8e1b44759e97ad7b116f4bf071f1e9 Mon Sep 17 00:00:00 2001
From: huang
Date: Sat, 25 Jul 2015 00:05:28 +0800
Subject: [PATCH 10/21] =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=8C=BA=E9=97=B4?=
=?UTF-8?q?=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/repositories_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 03ab9d2e3..e59d90052 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -710,7 +710,7 @@ update
all_author << cba.first
end
all_author = all_author.collect {|c| c.gsub(%r{<.+@.+>}, '') }
- commits_by_author = repository.commits(all_author, "#{@date_from}", "#{@date_to}")
+ commits_by_author = repository.commits(all_author, "2015-01-24", "2015-07-24")
Rails.logger.debug "######################################{commits_by_author}"
fields = commits_by_author.collect {|r| r.first}
From a04fe786ea246b10769f2da61a2d813e94e394d1 Mon Sep 17 00:00:00 2001
From: huang
Date: Sat, 25 Jul 2015 00:24:59 +0800
Subject: [PATCH 11/21] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E7=94=A8=E6=88=B7?=
=?UTF-8?q?=E5=90=8D=E5=90=8E=E7=9A=84=E7=A9=BA=E6=A0=BC=20=E6=97=B6?=
=?UTF-8?q?=E9=97=B4=E5=8C=BA=E9=97=B4=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/repositories_controller.rb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index e59d90052..3dee2af3e 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -709,7 +709,8 @@ update
commits_by_author.each do |cba|
all_author << cba.first
end
- all_author = all_author.collect {|c| c.gsub(%r{<.+@.+>}, '') }
+ # all_author = all_author.collect {|c| c.gsub(%r{/ /<.+@.+>}, '') }
+ all_author = all_author.collect {|c| c.split.first }
commits_by_author = repository.commits(all_author, "2015-01-24", "2015-07-24")
Rails.logger.debug "######################################{commits_by_author}"
From 5732d9cee24e10b04a1ba49c713325c34ee8321b Mon Sep 17 00:00:00 2001
From: guange <8863824@gmail.com>
Date: Sat, 25 Jul 2015 10:17:03 +0800
Subject: [PATCH 12/21] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E8=BE=93=E5=87=BA?=
=?UTF-8?q?=E6=97=A5=E5=BF=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
lib/redmine/scm/adapters/git_adapter.rb | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb
index 81c361f6e..6c56a7e24 100644
--- a/lib/redmine/scm/adapters/git_adapter.rb
+++ b/lib/redmine/scm/adapters/git_adapter.rb
@@ -404,6 +404,7 @@ module Redmine
git_cmd(cmd_args) do |io|
commits = io.read
end
+ logger.info "git log output for #{author} #{commits}"
rs << {author: author, num: parse_commit(commits)}
end
rs
From bf5f7f8d4f8d1b2ab5ae3969fa7b6a696a11b01a Mon Sep 17 00:00:00 2001
From: guange <8863824@gmail.com>
Date: Sat, 25 Jul 2015 11:18:09 +0800
Subject: [PATCH 13/21] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E5=88=86=E6=94=AF?=
=?UTF-8?q?=E5=8F=82=E6=95=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/repository/git.rb | 4 ++--
lib/redmine/scm/adapters/git_adapter.rb | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/models/repository/git.rb b/app/models/repository/git.rb
index 041175572..7c484e87f 100644
--- a/app/models/repository/git.rb
+++ b/app/models/repository/git.rb
@@ -38,8 +38,8 @@ class Repository::Git < Repository
'Git'
end
- def commits(authors, start_date, end_date)
- scm.commits(authors, start_date, end_date).map {|commit|
+ def commits(authors, start_date, end_date, branch='master')
+ scm.commits(authors, start_date, end_date,branch).map {|commit|
[commit[:author], commit[:num]]
}
end
diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb
index 6c56a7e24..927018b34 100644
--- a/lib/redmine/scm/adapters/git_adapter.rb
+++ b/lib/redmine/scm/adapters/git_adapter.rb
@@ -396,10 +396,10 @@ module Redmine
sum[:insertion] + sum[:deletion]
end
- def commits(authors, start_date, end_date)
+ def commits(authors, start_date, end_date, branch='master')
rs = []
authors.each do |author|
- cmd_args = %W|log --pretty=tformat: --shortstat --author=#{author} --since=#{start_date} --until=#{end_date}|
+ cmd_args = %W|log #{branch} --pretty=tformat: --shortstat --author=#{author} --since=#{start_date} --until=#{end_date}|
commits = ''
git_cmd(cmd_args) do |io|
commits = io.read
From 59a3072f818b67fea6ce275a7a8a4d984825cb4a Mon Sep 17 00:00:00 2001
From: huang
Date: Sat, 25 Jul 2015 11:20:11 +0800
Subject: [PATCH 14/21] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=97=B6=E9=97=B4?=
=?UTF-8?q?=E5=8C=BA=E6=AE=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/repositories_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 3dee2af3e..092d50843 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -711,7 +711,7 @@ update
end
# all_author = all_author.collect {|c| c.gsub(%r{/ /<.+@.+>}, '') }
all_author = all_author.collect {|c| c.split.first }
- commits_by_author = repository.commits(all_author, "2015-01-24", "2015-07-24")
+ commits_by_author = repository.commits(all_author, "2014-01-24", "2015-07-24")
Rails.logger.debug "######################################{commits_by_author}"
fields = commits_by_author.collect {|r| r.first}
From 405104c403e779650f0ebab4f7b2f2f3ac43f360 Mon Sep 17 00:00:00 2001
From: guange <8863824@gmail.com>
Date: Sat, 25 Jul 2015 11:46:29 +0800
Subject: [PATCH 15/21] =?UTF-8?q?=E4=BC=A0=E5=85=A5@rev?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/repositories_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 092d50843..8243a88cd 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -711,7 +711,7 @@ update
end
# all_author = all_author.collect {|c| c.gsub(%r{/ /<.+@.+>}, '') }
all_author = all_author.collect {|c| c.split.first }
- commits_by_author = repository.commits(all_author, "2014-01-24", "2015-07-24")
+ commits_by_author = repository.commits(all_author, "2015-01-24", "2015-07-24", @rev)
Rails.logger.debug "######################################{commits_by_author}"
fields = commits_by_author.collect {|r| r.first}
From 51e027fdc3c994c246dd5bf1b5178b73d4c9b30b Mon Sep 17 00:00:00 2001
From: guange <8863824@gmail.com>
Date: Sat, 25 Jul 2015 12:02:30 +0800
Subject: [PATCH 16/21] =?UTF-8?q?szzh=E7=89=B9=E6=AE=8A=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/repositories_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 8243a88cd..781bf0766 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -711,7 +711,7 @@ update
end
# all_author = all_author.collect {|c| c.gsub(%r{/ /<.+@.+>}, '') }
all_author = all_author.collect {|c| c.split.first }
- commits_by_author = repository.commits(all_author, "2015-01-24", "2015-07-24", @rev)
+ commits_by_author = repository.commits(all_author, "2015-01-24", "2015-07-24", repository.id == 150 ? "szzh" : 'master')
Rails.logger.debug "######################################{commits_by_author}"
fields = commits_by_author.collect {|r| r.first}
From fbc0f074d4d2d847e4c7757897768d1d80fdb688 Mon Sep 17 00:00:00 2001
From: huang
Date: Sat, 25 Jul 2015 12:04:06 +0800
Subject: [PATCH 17/21] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E9=87=8F=E7=BB=9F?=
=?UTF-8?q?=E8=AE=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/repositories_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 092d50843..08799ef01 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -711,7 +711,7 @@ update
end
# all_author = all_author.collect {|c| c.gsub(%r{/ /<.+@.+>}, '') }
all_author = all_author.collect {|c| c.split.first }
- commits_by_author = repository.commits(all_author, "2014-01-24", "2015-07-24")
+ commits_by_author = repository.commits(all_author, '@date_from', "@date_to", "szzh")
Rails.logger.debug "######################################{commits_by_author}"
fields = commits_by_author.collect {|r| r.first}
From b320a02976bca784de19541f105233d263d9a366 Mon Sep 17 00:00:00 2001
From: huang
Date: Sat, 25 Jul 2015 12:06:21 +0800
Subject: [PATCH 18/21] =?UTF-8?q?=E7=BB=9F=E8=AE=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/repositories_controller.rb | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 08799ef01..fc441e238 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -712,7 +712,6 @@ update
# all_author = all_author.collect {|c| c.gsub(%r{/ /<.+@.+>}, '') }
all_author = all_author.collect {|c| c.split.first }
commits_by_author = repository.commits(all_author, '@date_from', "@date_to", "szzh")
- Rails.logger.debug "######################################{commits_by_author}"
fields = commits_by_author.collect {|r| r.first}
commits_data = commits_by_author.collect {|r| r.last}
From 839cbf2a5565ccdfe959a2c4682efcf53a6c554d Mon Sep 17 00:00:00 2001
From: huang
Date: Sun, 26 Jul 2015 13:43:56 +0800
Subject: [PATCH 19/21] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=80=E5=B9=B4?=
=?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=AC=A1=E6=95=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/repositories_controller.rb | 13 +++++++------
config/locales/zh.yml | 1 +
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 355033b8f..bbc3e1596 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -626,14 +626,14 @@ update
graph.burn
end
- # 用户每月提交次数
+ # 用户最近一年的提交次数
def graph_author_commits_per_month(repository)
@date_to = Date.today
- @date_from = @date_to << 1
+ @date_from = @date_to << 12
@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)
+ commits_by_author = commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}.last(25)
fields = commits_by_author.collect {|r| r.first}
commits_data = commits_by_author.collect {|r| r.last}
@@ -652,8 +652,9 @@ update
:scale_integers => true,
:show_data_values => true,
:rotate_y_labels => false,
- :graph_title => l(:label_author_commits_per_month),
- :show_graph_title => true
+ :graph_title => l(:label_author_commits_year),
+ :show_graph_title => true,
+ :no_css => true
)
graph.add_data(
:data => commits_data,
@@ -735,7 +736,7 @@ update
)
graph.add_data(
:data => commits_data,
- :title => l(:label_revision_plural)
+ :title => l(:lable_revision_code_count)
)
graph.burn
end
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index a5f4f4d10..78e8379dc 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -669,6 +669,7 @@ zh:
label_tag: 标签
label_revision: 修订
label_revision_plural: 修订
+ lable_revision_code_count: 代码量
label_revision_id: 修订 %{value}
label_associated_revisions: 相关修订版本
label_added: 已添加
From d89cba7a1fa9338a2c1baa70acda2c66770e4f9d Mon Sep 17 00:00:00 2001
From: huang
Date: Sun, 26 Jul 2015 14:12:26 +0800
Subject: [PATCH 20/21] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E7=BB=9F?=
=?UTF-8?q?=E8=AE=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/repositories_controller.rb | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index bbc3e1596..41b44b6cd 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -670,7 +670,7 @@ update
@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)
+ commits_by_author = commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}.last(25)
fields = commits_by_author.collect {|r| r.first}
commits_data = commits_by_author.collect {|r| r.last}
@@ -705,7 +705,7 @@ update
@date_from = @date_to << 6
@date_from = Date.civil(@date_from.year, @date_from.month, @date_from.day)
commits_by_author = Changeset.count(: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)
+ commits_by_author = commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}.last(25)
all_author = []
commits_by_author.each do |cba|
all_author << cba.first
@@ -734,6 +734,10 @@ update
:graph_title => l(:label_author_code_six_month),
:show_graph_title => true
)
+ commits_data1 = [0]*12
+ graph.add_data(
+ :data => commits_data1,
+ )
graph.add_data(
:data => commits_data,
:title => l(:lable_revision_code_count)
From 46272a28cf42d41bd44257a5874dcce248ab2763 Mon Sep 17 00:00:00 2001
From: huang
Date: Sun, 26 Jul 2015 14:15:25 +0800
Subject: [PATCH 21/21] =
---
app/controllers/repositories_controller.rb | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 41b44b6cd..303e4a213 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -705,7 +705,7 @@ update
@date_from = @date_to << 6
@date_from = Date.civil(@date_from.year, @date_from.month, @date_from.day)
commits_by_author = Changeset.count(: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(25)
+ commits_by_author = commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}.last(40)
all_author = []
commits_by_author.each do |cba|
all_author << cba.first
@@ -734,10 +734,6 @@ update
:graph_title => l(:label_author_code_six_month),
:show_graph_title => true
)
- commits_data1 = [0]*12
- graph.add_data(
- :data => commits_data1,
- )
graph.add_data(
:data => commits_data,
:title => l(:lable_revision_code_count)