Merge branch 'hjq_beidou' into develop
Conflicts: db/schema.rb
This commit is contained in:
commit
6027b6d0f5
|
@ -319,9 +319,25 @@ class ProjectsController < ApplicationController
|
|||
else
|
||||
@events_pages = ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public = ? and forge_act_type != ? ",@project,1, "Document").order("created_at desc").page(params['page'|| 1]).per(10);
|
||||
end
|
||||
g = Gitlab.client
|
||||
# g = Gitlab.client
|
||||
unless @project.gpid.nil? || @project.project_score.changeset_num == 0
|
||||
@static_total_per_user = g.rep_stats(@project.gpid)
|
||||
# rep_statics_commit = @project.rep_statics.order("commits_num desc")
|
||||
rep_statics_commit = RepStatics.find_by_sql("SELECT * FROM `rep_statics` where project_id = #{@project.id} order by commits_num desc limit 10")
|
||||
rep_statics_code = RepStatics.find_by_sql("SELECT * FROM `rep_statics` where project_id = #{@project.id} order by changeset desc limit 10")
|
||||
# rep_statics_code = @project.rep_statics.sort_by {|u| u.changeset}.reverse
|
||||
@a_uname = rep_statics_commit.map {|s| s.uname }
|
||||
@a_uname_code = rep_statics_code.map {|s| s.uname }
|
||||
@a_commits_num = rep_statics_commit.map {|s| s.commits_num.to_i }
|
||||
@a_commits_add = rep_statics_code.map {|s| s.add.to_i }
|
||||
@a_commits_del = rep_statics_code.map {|s| s.del.to_i }
|
||||
@a_commits_changeset = rep_statics_code.map {|s| s.changeset.to_i }
|
||||
g = Gitlab.client
|
||||
begin
|
||||
g_branch = g.project(@project.gpid).default_branch.to_s
|
||||
rescue
|
||||
logger.error("get gitlab project failed!")
|
||||
end
|
||||
@rev = g_branch.nil? ? "master" : g_branch
|
||||
end
|
||||
# 根据对应的请求,返回对应的数据
|
||||
respond_to do |format|
|
||||
|
|
|
@ -348,8 +348,10 @@ update
|
|||
# (show_error_not_found; return) unless @entries
|
||||
g = Gitlab.client
|
||||
@changesets = g.commits(@project.gpid, :ref_name => @rev)
|
||||
g_project = g.project(@project.gpid)
|
||||
# 总的提交数
|
||||
@changesets_all_count = @project.gpid.nil? ? 0 : g.project(@project.gpid).commit_count
|
||||
@changesets_all_count = @project.gpid.nil? ? 0 : g_project.commit_count
|
||||
@g_default_branch = g_project.default_branch.nil? ? "master" : g_project.default_branch
|
||||
# 访问该页面的是会后则刷新
|
||||
if @project.project_score.nil?
|
||||
ProjectScore.create(:project_id => @project.id, :score => false)
|
||||
|
@ -573,7 +575,17 @@ update
|
|||
g = Gitlab.client
|
||||
begin
|
||||
@static_total_per_user = g.rep_stats(project_id, :rev => rev)
|
||||
@static_total_per_user
|
||||
# 更新rep_statics统计数
|
||||
@static_total_per_user.each do |static|
|
||||
rep_static = RepStatics.where("project_id =? and email =?", @project.id, static.email.to_s).first
|
||||
if rep_static.nil?
|
||||
RepStatics.create(:project_id => @project.id, :uname => static.uname, :commits_num => static.commits_num, :email => static.email, :add => static.add, :del => static.del, :changeset => static.changes)
|
||||
else
|
||||
if @rev == params[:default_branch]
|
||||
rep_static.update_attributes(:uname => static.uname, :commits_num => static.commits_num, :email => static.email, :add => static.add, :del => static.del, :changeset => static.changes)
|
||||
end
|
||||
end
|
||||
end
|
||||
# @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
|
||||
|
|
|
@ -115,6 +115,7 @@ class Project < ActiveRecord::Base
|
|||
|
||||
has_many :org_projects,:dependent => :destroy
|
||||
has_many :organization,:through => :org_projects
|
||||
has_many :rep_statics, :class_name => 'RepStatics'
|
||||
|
||||
# has_many :journals
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
class RepStatics < ActiveRecord::Base
|
||||
belongs_to :project
|
||||
attr_accessible :add, :commits_num, :del, :email, :project_id, :uname, :changeset
|
||||
end
|
|
@ -10,14 +10,18 @@
|
|||
type: 'line'
|
||||
},
|
||||
title: {
|
||||
text: '版本库代码提交量'
|
||||
text: '版本库代码提交行数',
|
||||
style:{
|
||||
fontSize: '14px'
|
||||
}
|
||||
|
||||
},
|
||||
subtitle: {
|
||||
// text: 'Source: WorldClimate.com'
|
||||
},
|
||||
xAxis: {
|
||||
// categories: ["Jan", "Jan", "Jan", 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
||||
categories: <%= raw(@static_total_per_user.map{|c| c.uname}) %>
|
||||
categories: <%= raw(@a_uname_code) %>
|
||||
},
|
||||
yAxis: {
|
||||
title: {
|
||||
|
@ -34,6 +38,12 @@
|
|||
}
|
||||
},
|
||||
plotOptions: {
|
||||
series: {
|
||||
marker: {
|
||||
radius: 3, //曲线点半径,默认是4
|
||||
symbol: 'circle' //曲线点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
|
||||
}
|
||||
},
|
||||
line: {
|
||||
dataLabels: {
|
||||
enabled: true
|
||||
|
@ -41,21 +51,55 @@
|
|||
enableMouseTracking: false
|
||||
}
|
||||
},
|
||||
series: [{
|
||||
name: '改动或增加',
|
||||
color: '#fd9e04',
|
||||
|
||||
// data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
|
||||
data: <%= @static_total_per_user.map{|c| c.add.to_i} %>
|
||||
series: [
|
||||
{
|
||||
name: '<b style="font-weight:normal ">总变更</b>',
|
||||
color: '#d05d5a',
|
||||
fontWeight: 'normal',
|
||||
data: <%= @a_commits_changeset %>,
|
||||
dataLabels: {
|
||||
enabled: false,
|
||||
style: {
|
||||
fontSize: '13px',
|
||||
color: '#aaa',
|
||||
fontFamily: 'Arial',
|
||||
textShadow: '0px 0px 6px rgb(0, 0, 0), 0px 0px 3px rgb(f, f, f)',
|
||||
fontWeight: 'normal'
|
||||
}
|
||||
},
|
||||
lineWidth: 1.5
|
||||
},
|
||||
{
|
||||
name: '<b style="font-weight:normal ">改动或增加</b>',
|
||||
color: '#5b6b76',
|
||||
data: <%= @a_commits_add %>,
|
||||
dataLabels: {
|
||||
enabled: false,
|
||||
style: {
|
||||
fontSize: '13px',
|
||||
color: '#aaa',
|
||||
fontFamily: 'Arial',
|
||||
textShadow: '0px 0px 6px rgb(0, 0, 0), 0px 0px 3px rgb(f, f, f)',
|
||||
fontWeight: 'normal'
|
||||
}
|
||||
},
|
||||
lineWidth: 1.5
|
||||
},
|
||||
{
|
||||
name: '删除',
|
||||
color: '#46baed ',
|
||||
data: <%= @static_total_per_user.map{|c| c.del.to_i} %>
|
||||
},{
|
||||
name: '总变更',
|
||||
color: '#d397d5',
|
||||
data: <%= @static_total_per_user.map{|c| c.changes.to_i} %>
|
||||
name: '<b style="font-weight:normal ">删除</b>',
|
||||
color: '#84b5bb',
|
||||
data: <%= @a_commits_del %>,
|
||||
dataLabels: {
|
||||
enabled: false,
|
||||
style: {
|
||||
fontSize: '13px',
|
||||
color: '#aaa',
|
||||
fontFamily: 'Arial',
|
||||
textShadow: '0px 0px 6px rgb(0, 0, 0), 0px 0px 3px rgb(f, f, f)',
|
||||
fontWeight: 'normal'
|
||||
}
|
||||
},
|
||||
lineWidth: 1.5
|
||||
}]
|
||||
});
|
||||
|
||||
|
@ -68,14 +112,18 @@
|
|||
enabled: false
|
||||
},
|
||||
title: {
|
||||
text: '版本库代码提交次数'
|
||||
text: '版本库代码提交次数',
|
||||
style:{
|
||||
fontSize: '14px'
|
||||
}
|
||||
|
||||
},
|
||||
subtitle: {
|
||||
// text: 'Source: WorldClimate.com'
|
||||
},
|
||||
xAxis: {
|
||||
// categories: ["Jan", "Jan", "Jan", 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
||||
categories: <%= raw(@static_total_per_user.map{|c| c.uname}) %>
|
||||
categories: <%= raw(@a_uname) %>
|
||||
},
|
||||
yAxis: {
|
||||
title: {
|
||||
|
@ -89,6 +137,12 @@
|
|||
}
|
||||
},
|
||||
plotOptions: {
|
||||
series: {
|
||||
marker: {
|
||||
radius: 3, //曲线点半径,默认是4
|
||||
symbol: 'circle' //曲线点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
|
||||
}
|
||||
},
|
||||
line: {
|
||||
dataLabels: {
|
||||
enabled: true
|
||||
|
@ -97,9 +151,24 @@
|
|||
}
|
||||
},
|
||||
series: [{
|
||||
name: '提交次数',
|
||||
name: '<b style="font-weight:normal ">提交次数</b>',
|
||||
fontWeight: 'normal',
|
||||
color: '#d05d5a',
|
||||
// data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
|
||||
data: <%= @static_total_per_user.map{|c| c.commits_num.to_i} %>
|
||||
data: <%= @a_commits_num %>,
|
||||
dataLabels: {
|
||||
enabled: false,
|
||||
|
||||
style: {
|
||||
fontSize: '13px',
|
||||
color: '#aaa',
|
||||
fontFamily: 'Arial',
|
||||
textShadow: '0px 0px 6px rgb(0, 0, 0), 0px 0px 3px rgb(f, f, f)',
|
||||
fontWeight: 'normal'
|
||||
}
|
||||
},
|
||||
lineWidth: 1.5
|
||||
|
||||
}
|
||||
// {
|
||||
// name: 'London',
|
||||
|
@ -109,3 +178,4 @@
|
|||
});
|
||||
});
|
||||
</script>
|
||||
<div class="button-rep">当前分支:<%= @rev %></div>
|
|
@ -25,7 +25,7 @@
|
|||
<textarea id="copy_rep_content" class="cloneUrl mt5 fl" type="input" ><%= @repository.type.to_s=="Repository::Gitlab" ? @repos_url.to_s.lstrip : @repository.url %></textarea>
|
||||
<a href="javascript:void(0);" class="clone_btn mt5" onclick="jsCopy()"><span class="vl_copy" title="点击复制版本库地址"></span></a>
|
||||
<div class="fl mt5 ml15">
|
||||
<%=link_to "统计", stats_repository_project_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :creator => @creator ), :class => "fl vl_zip" %>
|
||||
<%=link_to "统计", stats_repository_project_path(:id => @project.id, :repository_id => @repository.identifier, :rev => @rev, :creator => @creator, :default_branch => @g_default_branch ), :class => "fl vl_zip" %>
|
||||
</div>
|
||||
<%# 针对公开项目:用户必须创建了项目,否则用户无法同步 %>
|
||||
<% if User.current.id != @project.user_id %>
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
</div>
|
||||
<div id = "container_code" class="mt30">
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
$('#container_code').highcharts({
|
||||
|
@ -21,7 +22,11 @@
|
|||
type: 'line'
|
||||
},
|
||||
title: {
|
||||
text: '代码提交量'
|
||||
text: '版本库代码提交行数',
|
||||
style:{
|
||||
fontSize: '14px'
|
||||
}
|
||||
|
||||
},
|
||||
subtitle: {
|
||||
// text: 'Source: WorldClimate.com'
|
||||
|
@ -45,6 +50,12 @@
|
|||
}
|
||||
},
|
||||
plotOptions: {
|
||||
series: {
|
||||
marker: {
|
||||
radius: 3, //曲线点半径,默认是4
|
||||
symbol: 'circle' //曲线点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
|
||||
}
|
||||
},
|
||||
line: {
|
||||
dataLabels: {
|
||||
enabled: true
|
||||
|
@ -52,18 +63,55 @@
|
|||
enableMouseTracking: false
|
||||
}
|
||||
},
|
||||
series: [{
|
||||
name: '改动或增加',
|
||||
|
||||
// data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
|
||||
data: <%= @static_total_per_user.map{|c| c.add.to_i} %>
|
||||
},
|
||||
{
|
||||
name: '删除',
|
||||
data: <%= @static_total_per_user.map{|c| c.del.to_i} %>
|
||||
},{
|
||||
name: '总变更',
|
||||
data: <%= @static_total_per_user.map{|c| c.changes.to_i} %>
|
||||
series: [
|
||||
{
|
||||
name: '<b style="font-weight:normal ">总变更</b>',
|
||||
color: '#d05d5a',
|
||||
fontWeight: 'normal',
|
||||
data: <%= @static_total_per_user.map{|c| c.changes.to_i} %>,
|
||||
dataLabels: {
|
||||
enabled: true,
|
||||
style: {
|
||||
fontSize: '13px',
|
||||
color: '#aaa',
|
||||
fontFamily: 'Arial',
|
||||
textShadow: '0px 0px 6px rgb(0, 0, 0), 0px 0px 3px rgb(f, f, f)',
|
||||
fontWeight: 'normal'
|
||||
}
|
||||
},
|
||||
lineWidth: 1.5
|
||||
},
|
||||
{
|
||||
name: '<b style="font-weight:normal ">改动或增加</b>',
|
||||
color: '#5b6b76',
|
||||
data: <%= @static_total_per_user.map{|c| c.add.to_i} %>,
|
||||
dataLabels: {
|
||||
enabled: true,
|
||||
style: {
|
||||
fontSize: '13px',
|
||||
color: '#aaa',
|
||||
fontFamily: 'Arial',
|
||||
textShadow: '0px 0px 6px rgb(0, 0, 0), 0px 0px 3px rgb(f, f, f)',
|
||||
fontWeight: 'normal'
|
||||
}
|
||||
},
|
||||
lineWidth: 1.5
|
||||
},
|
||||
{
|
||||
name: '<b style="font-weight:normal ">删除</b>',
|
||||
color: '#84b5bb',
|
||||
data: <%= @static_total_per_user.map{|c| c.del.to_i} %>,
|
||||
dataLabels: {
|
||||
enabled: true,
|
||||
style: {
|
||||
fontSize: '13px',
|
||||
color: '#aaa',
|
||||
fontFamily: 'Arial',
|
||||
textShadow: '0px 0px 6px rgb(0, 0, 0), 0px 0px 3px rgb(f, f, f)',
|
||||
fontWeight: 'normal'
|
||||
}
|
||||
},
|
||||
lineWidth: 1.5
|
||||
}]
|
||||
});
|
||||
|
||||
|
@ -76,14 +124,18 @@
|
|||
enabled: false
|
||||
},
|
||||
title: {
|
||||
text: '代码提交次数'
|
||||
text: '版本库代码提交次数',
|
||||
style:{
|
||||
fontSize: '14px'
|
||||
}
|
||||
|
||||
},
|
||||
subtitle: {
|
||||
// text: 'Source: WorldClimate.com'
|
||||
},
|
||||
xAxis: {
|
||||
// categories: ["Jan", "Jan", "Jan", 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
||||
categories: <%= raw(@static_total_per_user.map{|c| c.uname}) %>
|
||||
categories: <%= raw(@static_total_per_user.map{|c| c.uname}) %>
|
||||
},
|
||||
yAxis: {
|
||||
title: {
|
||||
|
@ -97,6 +149,12 @@
|
|||
}
|
||||
},
|
||||
plotOptions: {
|
||||
series: {
|
||||
marker: {
|
||||
radius: 3, //曲线点半径,默认是4
|
||||
symbol: 'circle' //曲线点类型:"circle", "square", "diamond", "triangle","triangle-down",默认是"circle"
|
||||
}
|
||||
},
|
||||
line: {
|
||||
dataLabels: {
|
||||
enabled: true
|
||||
|
@ -105,9 +163,23 @@
|
|||
}
|
||||
},
|
||||
series: [{
|
||||
name: '提交次数',
|
||||
name: '<b style="font-weight:normal ">提交次数</b>',
|
||||
fontWeight: 'normal',
|
||||
color: '#d05d5a',
|
||||
// data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
|
||||
data: <%= @static_total_per_user.map{|c| c.commits_num.to_i} %>
|
||||
data: <%= @static_total_per_user.map{|c| c.commits_num.to_i} %>,
|
||||
dataLabels: {
|
||||
enabled: true,
|
||||
style: {
|
||||
fontSize: '13px',
|
||||
color: '#aaa',
|
||||
fontFamily: 'Arial',
|
||||
textShadow: '0px 0px 6px rgb(0, 0, 0), 0px 0px 3px rgb(f, f, f)',
|
||||
fontWeight: 'normal'
|
||||
}
|
||||
},
|
||||
lineWidth: 1.5
|
||||
|
||||
}
|
||||
// {
|
||||
// name: 'London',
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
class CreateRepStatics < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :rep_statics do |t|
|
||||
t.integer :project_id
|
||||
t.integer :commits_num
|
||||
t.string :uname
|
||||
t.string :email
|
||||
t.integer :add
|
||||
t.integer :del
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddChangesetToRepStatics < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :rep_statics, :changeset, :integer
|
||||
end
|
||||
end
|
|
@ -0,0 +1,26 @@
|
|||
class SyncRepStatics < ActiveRecord::Migration
|
||||
def up
|
||||
g = Gitlab.client
|
||||
# projects = Project.find_by_sql("SELECT p.* FROM projects p, project_scores ps where p.id = ps.project_id and p.gpid is not null and ps.changeset_num > 0")
|
||||
projects = Project.where("gpid is not null")
|
||||
count = projects.count / 30 + 2
|
||||
transaction do
|
||||
for i in 1 ... count do i
|
||||
projects.page(i).per(30).each do |project|
|
||||
begin
|
||||
puts project.id
|
||||
g.rep_stats(project.gpid).each do |static|
|
||||
puts static.uname
|
||||
RepStatics.create(:project_id => project.id, :uname => static.uname, :commits_num => static.commits_num, :email => static.email, :add => static.add, :del => static.del, :changeset => static.changes)
|
||||
end
|
||||
rescue
|
||||
logger.error("Sync rep failed!")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -1200,3 +1200,4 @@ a.chooseActive {background-color:#269ac9; color:#ffffff;}
|
|||
.popupClose {background:url(../images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000; right:10px; top:5px;}
|
||||
.subjectType {width:70px; text-align:center;}
|
||||
.subjectCount {width:65px; text-align:center;}
|
||||
.button-rep { color: #888;display: inline-block;background: #eee;padding: 2px 5px;}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
FactoryGirl.define do
|
||||
factory :rep_static, :class => 'RepStatics' do
|
||||
project_id 1
|
||||
commits_num 1
|
||||
uname "MyString"
|
||||
email "MyString"
|
||||
add 1
|
||||
del 1
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe RepStatics, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue