diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index dac4034d0..698fd1136 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -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 diff --git a/app/views/repositories/stats.html.erb b/app/views/repositories/stats.html.erb index b4e4c92a3..5739eb35a 100644 --- a/app/views/repositories/stats.html.erb +++ b/app/views/repositories/stats.html.erb @@ -1,30 +1,60 @@ -
- <%= 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")) %> -
-- <%# 用户每月提交代码次数 %> - <%= 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")) %> -
-- <%= 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")) %> -
-- <%# 用户最近六个月的提交次数 %> - <%= 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")) %> -
-- <%# 用户最近六个月的代码量 %> - <%= 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")) %> -
+ + + + + + + + + + + + + + + + +总情况
+ <% @static_total_per_user.each do |commit| %> +总提交次数
+ <%= commit.uname %>:<%= commit.commits_num %> +总提交代码量
+ <%= commit.uname %>:总提交次数<%= commit.commits_num %> + <%= commit.add %> + <%= commit.del %> + <% end %> + + +月情况
+ <% @static_month__per_user.each do |commit| %> +总提交次数
+ <%= commit.commits_num %> +总提交代码量
+ <%= commit.add %> + <%= commit.del %> + <% end %> + + +周情况
+ <% @static_week_per_user.each do |commit| %> +总提交次数
+ <%= commit.commits_num %> +总提交代码量
+ <%= commit.add %> + <%= commit.del %> + <% end %> +<%= link_to l(:button_back), :action => 'show', :id => @project %>
<% html_title(l(:label_repository), l(:label_statistics)) -%> <% end %> \ No newline at end of file diff --git a/lib/gitlab-cli/lib/gitlab/client/repositories.rb b/lib/gitlab-cli/lib/gitlab/client/repositories.rb index 8824ca3e9..98a8ea150 100644 --- a/lib/gitlab-cli/lib/gitlab/client/repositories.rb +++ b/lib/gitlab-cli/lib/gitlab/client/repositories.rb @@ -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