Merge branch 'rep_quality' of https://git.trustie.net/jacknudt/trustieforge into rep_quality

This commit is contained in:
daiao 2016-09-27 17:01:20 +08:00
commit e730312ec3
5 changed files with 25 additions and 12 deletions

View File

@ -77,7 +77,7 @@ class RepositoriesController < ApplicationController
respond_to do |format|
format.html
format.xls{
filename = "#{@project.name.to_s}_#{l(:label_issue_list_xls)}_#{@rev}_#{l(:label_rep_xls)}.xls"
filename = "#{@project.name.to_s}_#{l(:label_rep_xls)}.xls"
send_data(export_rep_xls(gpid, :rev => rev, :cycle => "1"), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
}
end

View File

@ -68,29 +68,31 @@ module ApplicationHelper
g = Gitlab.client
cycle = params[:cycle]
rev = params[:rev]
# branch = g.branche(gpid, rev)
statics = g.rep_stats(gpid, :rev => rev)
if cycle == "week"
statics = g.rep_stats_week(gpid, :rev => rev)
elsif cycle == "month"
statics = g.rep_stats_month(gpid, :rev => rev)
end
xls_report = StringIO.new
book = Spreadsheet::Workbook.new
sheet1 = book.create_worksheet :name => "版本库"
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
sheet1.row(0).default_format = blue
sheet1.row(0).concat([l(:rep_branch),l(:rep_author),l(:rep_author_mail),l(:rep_code_add),l(:rep_code_delete),l(:rep_code_modified),l(:rep_sode_time),l(:rep_sode_cycle)])
sheet1.row(0).concat([l(:rep_branch),l(:rep_author),l(:rep_changeset),l(:rep_code_add),l(:rep_code_delete),l(:rep_code_modified),l(:rep_sode_time),l(:rep_sode_cycle),l(:rep_author_mail)])
count_row = 1
statics.each do |static|
user = User.where(:mail => static.email).first
sheet1[count_row,0] = rev
sheet1[count_row,1] = user.nil? ? static.uname : user.show_name
sheet1[count_row,2] = static.email
sheet1[count_row,2] = static.commits_num
sheet1[count_row,3] = static.add
sheet1[count_row,4] = static.del
sheet1[count_row,5] = static.changes
sheet1[count_row,6] = Time.now
sheet1[count_row,7] = "1周"
sheet1[count_row,6] = Time.now.strftime('%Y-%m-%d %H:%M:%S')
sheet1[count_row,7] = cycle == "week" ? "最近1周" : "最近一月"
sheet1[count_row,8] = static.email
count_row += 1
end
book.write xls_report
xls_report.string
end

View File

@ -80,8 +80,8 @@
<a href="https://<%=Setting.host_name %>/forums/1/memos/1232" >如何提交代码</a>
<div class="fr">
<a style="color: #7f7f7f;">导出统计结果:</a>
<%= link_to "当前一周", {:controller => 'repositories', :action => 'export_rep_static', :format => 'xls', :rev => @rev, :cycle => "week" } %> <a style="color: #7f7f7f;">|</a>
<%= link_to "当前一月", {:controller => 'repositories', :action => 'export_rep_static', :format => 'xls', :rev => @rev, :cycle => "month" } %>
<%= link_to "最近一周", {:controller => 'repositories', :action => 'export_rep_static', :format => 'xls', :rev => @rev, :cycle => "week" } %> <a style="color: #7f7f7f;">|</a>
<%= link_to "最近一月", {:controller => 'repositories', :action => 'export_rep_static', :format => 'xls', :rev => @rev, :cycle => "month" } %>
</div>
<%#= link_to "导出excel", {:controller => 'repositories', :action => 'export_rep_static', :rev => @rev}, :format => 'xls' %>

View File

@ -222,11 +222,12 @@ zh:
rep_branch: 分支
rep_author: 作者
rep_author_mail: 邮箱
rep_changeset: 提交次数
rep_code_add: 添加行数
rep_code_delete: 删除代码
rep_code_modified: 总行数
rep_sode_time: 导出时间
rep_sode_cycle: 周期
rep_sode_cycle: 时间区间
# 自定义查询
label_query_plural: 自定义查询

View File

@ -117,6 +117,16 @@ class Gitlab::Client
end
alias_method :repo_rep_stats, :rep_stats
def rep_stats_week(project, options={})
get("/projects/#{project}/repository/rep_stats_week", :query => options)
end
alias_method :repo_rep_stats, :rep_stats
def rep_stats_month(project, options={})
get("/projects/#{project}/repository/rep_stats_month", :query => options)
end
alias_method :repo_rep_stats, :rep_stats
def rep_user_stats(project, options={})
get("/projects/#{project}/repository/rep_user_stats", :query => options)
end