gitlab版本库添加提交信息统计接口
This commit is contained in:
parent
04849659de
commit
f7cb451feb
|
@ -30,7 +30,7 @@ class RepositoriesController < ApplicationController
|
|||
menu_item :settings, :only => [:new, :create, :edit, :update, :destroy, :committers]
|
||||
default_search_scope :changesets
|
||||
|
||||
before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo]
|
||||
before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo, :stats]
|
||||
before_filter :find_repository, :only => [:edit, :update, :destroy, :committers]
|
||||
before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo, :to_gitlab, :forked]
|
||||
before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue]
|
||||
|
@ -562,10 +562,23 @@ update
|
|||
end
|
||||
|
||||
def stats
|
||||
@project_id = params[:id]
|
||||
if @project.gpid.nil?
|
||||
render 404
|
||||
return
|
||||
end
|
||||
project_id = @project.gpid
|
||||
@repository_id = @repository.identifier
|
||||
# 提交次数统计
|
||||
@status_commit_count = Changeset.count(:conditions => ["#{Changeset.table_name}.repository_id = ?", @repository.id])
|
||||
creator = params[:creator]
|
||||
rev = params[:rev]
|
||||
g = Gitlab.client
|
||||
begin
|
||||
@static_total_per_user = g.rep_stats(project_id, :rev => rev, :creator => creator, :period => 1)
|
||||
@static_month__per_user = g.rep_stats(project_id, :rev => rev, :creator => creator, :period => 2)
|
||||
@static_week_per_user = g.rep_stats(project_id, :rev => rev, :creator => creator, :period => 3)
|
||||
rescue
|
||||
render_404
|
||||
return
|
||||
end
|
||||
render :layout => 'base_projects'
|
||||
end
|
||||
|
||||
|
|
|
@ -1,30 +1,60 @@
|
|||
<div class="project_r_h">
|
||||
<div class="project_r_h" xmlns="http://www.w3.org/1999/html">
|
||||
<h2 class="project_h2"><%= l(:label_statistics) %></h2>
|
||||
</div>
|
||||
<% if false %>
|
||||
<div class="flash notice">请在版本库中提交代码,统计信息将更准确</div>
|
||||
<% else %>
|
||||
<div class="riviseRed fl"></div><div class="fl">修订 是版本库的提交次数, 显示为橘红色。</div><br>
|
||||
<div class="riviseRed fl"></div><div class="fl">删除 是版本库的提交次数, 显示为橘红色。</div><br>
|
||||
<div class="changeBlue fl"></div><div class="fl">变更 是对版本库中文件的修改次数, 显示为蓝色。</div>
|
||||
|
||||
<p style="padding-top:35px;">
|
||||
<%= 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_commits_six_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_code_six_months")) %>
|
||||
</p>
|
||||
<!--<div class="resourcesSendTo">-->
|
||||
<!--<select class="projectRepType" onclick="chooseCommitType('<%#= @project_id %>', '<%#= @repository_id %>');">-->
|
||||
<!--<option value="1">总提交</option>-->
|
||||
<!--<option value="2">一个月内</option>-->
|
||||
<!--<option value="3">一周内</option>-->
|
||||
<!--</select>-->
|
||||
<!--</div>-->
|
||||
|
||||
<!--提交总数-->
|
||||
<!--<div id="rep_commit_stats">-->
|
||||
<!--100次提交-->
|
||||
<!--</div>-->
|
||||
|
||||
<!--<div id="rep_code_stats">-->
|
||||
<!--1000行代码-->
|
||||
<!--</div>-->
|
||||
<div >
|
||||
<p>总情况</p>
|
||||
<% @static_total_per_user.each do |commit| %>
|
||||
<p>总提交次数</p>
|
||||
<%= commit.uname %>:<%= commit.commits_num %>
|
||||
<p>总提交代码量</p>
|
||||
<%= commit.uname %>:总提交次数<%= commit.commits_num %>
|
||||
<%= commit.add %>
|
||||
<%= commit.del %>
|
||||
<% end %>
|
||||
</br>
|
||||
</br>
|
||||
<p class="color:red">月情况</p>
|
||||
<% @static_month__per_user.each do |commit| %>
|
||||
<p>总提交次数</p>
|
||||
<%= commit.commits_num %>
|
||||
<p>总提交代码量</p>
|
||||
<%= commit.add %>
|
||||
<%= commit.del %>
|
||||
<% end %>
|
||||
</br>
|
||||
</br>
|
||||
<p class="color:red">周情况</p>
|
||||
<% @static_week_per_user.each do |commit| %>
|
||||
<p>总提交次数</p>
|
||||
<%= commit.commits_num %>
|
||||
<p>总提交代码量</p>
|
||||
<%= commit.add %>
|
||||
<%= commit.del %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<p><%= link_to l(:button_back), :action => 'show', :id => @project %></p>
|
||||
<% html_title(l(:label_repository), l(:label_statistics)) -%>
|
||||
<% end %>
|
|
@ -89,6 +89,23 @@ class Gitlab::Client
|
|||
end
|
||||
alias_method :repo_commit, :commit
|
||||
|
||||
# Gets a statics of project repository.
|
||||
#
|
||||
# @example
|
||||
# Gitlab.commits('viking')
|
||||
# Gitlab.repo_commits('gitlab', :ref_name => 'api')
|
||||
#
|
||||
# @param [Integer] project The ID of a project.
|
||||
# @param [Hash] options A customizable set of options.
|
||||
# @option options [String] :ref_name The branch or tag name of a project repository.
|
||||
# @option options [String] :creator The user name of a project repository.
|
||||
# @option options [Integer] :period Statistics over time. 1:total 2:one month 3:one week
|
||||
# @return [Array<Gitlab::ObjectifiedHash>]
|
||||
def rep_stats(project, options={})
|
||||
get("/projects/#{project}/repository/rep_stats", :query => options)
|
||||
end
|
||||
alias_method :repo_rep_stats, :rep_stats
|
||||
|
||||
# Get the diff of a commit in a project.
|
||||
#
|
||||
# @example
|
||||
|
|
Loading…
Reference in New Issue