Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
d38b840c4b
|
@ -250,10 +250,8 @@ module Mobile
|
|||
end
|
||||
get "course_dynamic/:id" do
|
||||
cs = CoursesService.new
|
||||
p Time.now.to_s
|
||||
count = cs.all_course_dynamics(params,current_user)
|
||||
present :data, count, with: Mobile::Entities::CourseDynamic
|
||||
p Time.now.to_s
|
||||
present :status, 0
|
||||
end
|
||||
|
||||
|
|
|
@ -4,45 +4,44 @@ module Mobile
|
|||
include Redmine::I18n
|
||||
def self.course_dynamic_expose(field)
|
||||
expose field do |c,opt|
|
||||
if field == :news_count
|
||||
obj = nil
|
||||
c[:dynamics].each do |d|
|
||||
if d[:type] == 1
|
||||
obj = d[:count]
|
||||
end
|
||||
end
|
||||
obj
|
||||
elsif field == :document_count
|
||||
obj = nil
|
||||
c[:dynamics].each do |d|
|
||||
if d[:type] == 3
|
||||
obj = d[:count]
|
||||
end
|
||||
end
|
||||
obj
|
||||
elsif field == :topic_count
|
||||
obj = nil
|
||||
c[:dynamics].each do |d|
|
||||
if d[:type] == 2
|
||||
obj = d[:count]
|
||||
end
|
||||
end
|
||||
obj
|
||||
elsif field == :homework_count
|
||||
obj = nil
|
||||
c[:dynamics].each do |d|
|
||||
if d[:type] == 4
|
||||
obj = d[:count]
|
||||
end
|
||||
end
|
||||
obj
|
||||
else
|
||||
# if field == :news_count
|
||||
# obj = nil
|
||||
# c[:dynamics].each do |d|
|
||||
# if d[:type] == 1
|
||||
# obj = d[:count]
|
||||
# end
|
||||
# end
|
||||
# obj
|
||||
# elsif field == :document_count
|
||||
# obj = nil
|
||||
# c[:dynamics].each do |d|
|
||||
# if d[:type] == 3
|
||||
# obj = d[:count]
|
||||
# end
|
||||
# end
|
||||
# obj
|
||||
# elsif field == :topic_count
|
||||
# obj = nil
|
||||
# c[:dynamics].each do |d|
|
||||
# if d[:type] == 2
|
||||
# obj = d[:count]
|
||||
# end
|
||||
# end
|
||||
# obj
|
||||
# elsif field == :homework_count
|
||||
# obj = nil
|
||||
# c[:dynamics].each do |d|
|
||||
# if d[:type] == 4
|
||||
# obj = d[:count]
|
||||
# end
|
||||
# end
|
||||
# obj
|
||||
# else
|
||||
c[field] if (c.is_a?(Hash) && c.key?(field))
|
||||
end
|
||||
# end
|
||||
|
||||
end
|
||||
end
|
||||
course_dynamic_expose :type
|
||||
course_dynamic_expose :course_name
|
||||
course_dynamic_expose :course_term
|
||||
course_dynamic_expose :course_time
|
||||
|
@ -68,52 +67,22 @@ module Mobile
|
|||
# obj
|
||||
# end
|
||||
expose :topics,using:Mobile::Entities::Message do |f,opt|
|
||||
obj = nil
|
||||
f[:dynamics].each do |d|
|
||||
if d[:type] == 2
|
||||
obj = d[:topics]
|
||||
end
|
||||
end
|
||||
obj
|
||||
f[:topics]
|
||||
end
|
||||
expose :homeworks,using:Mobile::Entities::Homework do |f,opt|
|
||||
obj = nil
|
||||
f[:dynamics].each do |d|
|
||||
if d[:type] == 4
|
||||
obj = d[:homeworks]
|
||||
end
|
||||
end
|
||||
obj
|
||||
f[:homeworks]
|
||||
end
|
||||
|
||||
expose :news,using:Mobile::Entities::News do |f,opt|
|
||||
obj = nil
|
||||
f[:dynamics].each do |d|
|
||||
if d[:type] == 1
|
||||
obj = d[:news]
|
||||
end
|
||||
end
|
||||
obj
|
||||
f[:news]
|
||||
end
|
||||
|
||||
expose :better_students,using:Mobile::Entities::User do |f,opt|
|
||||
obj = nil
|
||||
f[:dynamics].each do |d|
|
||||
if d[:type] == 6
|
||||
obj = d[:better_students]
|
||||
end
|
||||
end
|
||||
obj
|
||||
f[:better_students]
|
||||
end
|
||||
|
||||
expose :active_students,using:Mobile::Entities::User do |f,opt|
|
||||
obj = nil
|
||||
f[:dynamics].each do |d|
|
||||
if d[:type] == 7
|
||||
obj = d[:active_students]
|
||||
end
|
||||
end
|
||||
obj
|
||||
f[:active_students]
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -459,6 +459,12 @@ update
|
|||
data = graph_commits_per_month(@repository)
|
||||
when "commits_per_author"
|
||||
data = graph_commits_per_author(@repository)
|
||||
when "author_commits_per_month"
|
||||
data = graph_author_commits_per_month(@repository)
|
||||
when "author_commits_six_month"
|
||||
data = author_commits_six_month(@repository)
|
||||
when "author_qoc_per_author"
|
||||
data = graph_author_qoc_per_author(@repository)
|
||||
end
|
||||
if data
|
||||
headers["Content-Type"] = "image/svg+xml"
|
||||
|
@ -617,6 +623,80 @@ update
|
|||
)
|
||||
graph.burn
|
||||
end
|
||||
|
||||
# 用户每月提交次数
|
||||
def graph_author_commits_per_month(repository)
|
||||
@date_to = Date.today
|
||||
@date_from = @date_to << 1
|
||||
@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)
|
||||
|
||||
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_per_month),
|
||||
:show_graph_title => true
|
||||
)
|
||||
graph.add_data(
|
||||
:data => commits_data,
|
||||
:title => l(:label_revision_plural)
|
||||
)
|
||||
graph.burn
|
||||
end
|
||||
|
||||
# 用户最近六个月的提交次数
|
||||
def author_commits_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(: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)
|
||||
|
||||
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])
|
||||
if !User.current.member_of?(project)
|
||||
|
|
|
@ -670,18 +670,25 @@ class CoursesService
|
|||
membership.each do |mp|
|
||||
course = mp.course
|
||||
latest_course_dynamics = []
|
||||
notices_count = 0
|
||||
topic_count = 0
|
||||
topics = nil
|
||||
homeworkss = nil
|
||||
notices = nil
|
||||
|
||||
# 课程通知
|
||||
latest_news = course.news.page(1).per(2).order("created_on desc")
|
||||
unless latest_news.first.nil?
|
||||
latest_course_dynamics << {:type => 1, :time => latest_news.first.created_on,:count=>course.news.count,
|
||||
:news => latest_news.all}
|
||||
notices_count = course.news.count
|
||||
notices = latest_news.all
|
||||
latest_course_dynamics << {:time => latest_news.first.created_on }
|
||||
end
|
||||
# 课程讨论区
|
||||
latest_message = course.boards.first.topics.page(1).per(2)
|
||||
unless latest_message.first.nil?
|
||||
latest_course_dynamics << {:type => 2, :time => latest_message.first.created_on, :count =>course.boards.nil? ? 0 : course.boards.first.topics.count,
|
||||
:topics => latest_message.all}
|
||||
topic_count = course.boards.nil? ? 0 : course.boards.first.topics.count
|
||||
topics = latest_message.all
|
||||
latest_course_dynamics << {:time => latest_message.first.created_on}
|
||||
end
|
||||
# 课程资源
|
||||
# latest_attachment = course.attachments.order("created_on desc").page(1).per(2)
|
||||
|
@ -693,7 +700,8 @@ class CoursesService
|
|||
#课程作业 已经交的学生列表(暂定显示6人),未交的学生列表,作业的状态
|
||||
homeworks = course.homework_commons.page(1).per(2).order('created_at desc')
|
||||
unless homeworks.first.nil?
|
||||
latest_course_dynamics << {:type => 4, :time => homeworks.first.updated_at, :count=>course.homework_commons.count , :homeworks => homeworks}
|
||||
homeworkss = homeworks
|
||||
latest_course_dynamics << {:time => homeworks.first.updated_at}
|
||||
end
|
||||
latest_course_dynamics.sort! { |order, newer| newer[:time] <=> order[:time] }
|
||||
# 课程学霸 学生总分数排名靠前的5个人
|
||||
|
@ -713,10 +721,10 @@ class CoursesService
|
|||
active_students = User.find_by_sql(sql1)
|
||||
|
||||
if homework_count != 0 && !better_students.empty?
|
||||
latest_course_dynamics <<{:type=> 6,:time=>"1970-01-01 0:0:0 +0800",:count=> 4,:better_students=> better_students}
|
||||
latest_course_dynamics <<{:time=>"1970-01-01 0:0:0 +0800"}
|
||||
end
|
||||
unless active_students.empty?
|
||||
latest_course_dynamics <<{:type=> 7,:time=>"1970-01-01 0:0:0 +0800",:count=> 4,:active_students=>active_students}
|
||||
latest_course_dynamics <<{:time=>"1970-01-01 0:0:0 +0800"}
|
||||
end
|
||||
latest_course_dynamic = latest_course_dynamics.first
|
||||
unless latest_course_dynamic.nil?
|
||||
|
@ -727,8 +735,15 @@ class CoursesService
|
|||
:course_img_url => url_to_avatar(course),
|
||||
:course_time => course.time,
|
||||
:course_term => course.term,
|
||||
:news_count => notices_count,
|
||||
:homework_count => homework_count,
|
||||
:topic_count => topic_count,
|
||||
:news => notices,
|
||||
:homeworks => homeworkss,
|
||||
:topics => topics,
|
||||
:better_students => better_students,
|
||||
:active_students => active_students,
|
||||
:message => "",
|
||||
:dynamics => latest_course_dynamics,
|
||||
:course_student_num=>course ? course.members.count : 0,
|
||||
#:time_from_now=> distance_of_time_in_words(Time.now, latest_course_dynamic[:time].to_time) << "前",
|
||||
:time_from_now=>time_from_now(latest_course_dynamic[:time].to_time), #.strftime('%Y-%m-%d %H:%M:%S').to_s,
|
||||
|
|
|
@ -5,27 +5,27 @@
|
|||
<!--JS进度条-->
|
||||
<style type="text/css">
|
||||
#out{}
|
||||
#in{width:10px; height:20px;background:#15BCCF;color:white;text-align:center;}
|
||||
#in{}
|
||||
#font_color{background:yellow;text-align:center;color:white;}
|
||||
</style>
|
||||
<div style="padding-left: 200px;">
|
||||
<div id='out'>
|
||||
<p style="padding-left: 120px;padding-bottom: 10px;font-size: 14px;">云化部署中...</p>
|
||||
<div style="width:300px;height:20px;background:#EEE;">
|
||||
<div id="in" style="width:1%">0%</div>
|
||||
<p style="padding-left: 100px;padding-bottom: 10px;font-size: 14px;padding-top: 10px;">云化部署中....</p>
|
||||
<div>
|
||||
<div id="in" style="width:0%"></div>
|
||||
<div>
|
||||
<script type="text/javascript">
|
||||
i=0;
|
||||
$(function(){
|
||||
ba=setInterval("begin()",50);//setInterval 返回的是一个全局变量,一个间隔数值.这个数值是表示调用setInterval的次数
|
||||
ba=setInterval("begin()",60);//setInterval 返回的是一个全局变量,一个间隔数值.这个数值是表示调用setInterval的次数
|
||||
});
|
||||
function begin()
|
||||
{
|
||||
i+=1;
|
||||
if(i<=100)
|
||||
{
|
||||
document.getElementById("in").style.width=i+"%";
|
||||
document.getElementById("in").innerHTML=i+"%";}
|
||||
document.getElementById("in").style.width="";
|
||||
document.getElementById("in").innerHTML="";}
|
||||
else
|
||||
{
|
||||
clearInterval(ba);
|
||||
|
|
|
@ -1,11 +1,29 @@
|
|||
<div class="project_r_h">
|
||||
<h2 class="project_h2"><%= l(:label_statistics) %></h2>
|
||||
</div>
|
||||
<p>
|
||||
<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_qoc_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_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_qoc_per_author")) %>
|
||||
</p>
|
||||
<p><%= link_to l(:button_back), :action => 'show', :id => @project %></p>
|
||||
<% html_title(l(:label_repository), l(:label_statistics)) -%>
|
||||
|
|
|
@ -715,6 +715,9 @@ zh:
|
|||
|
||||
label_commits_per_month: 每月提交次数
|
||||
label_commits_per_author: 每用户提交次数
|
||||
label_author_commits_per_month: 用户最近一月的提交次数
|
||||
label_author_commits_six_month: 用户最近六个月的提交次数
|
||||
label_author_commits_year: 最近一年的提交次数
|
||||
label_view_diff: 查看差别
|
||||
label_diff_inline: 直列
|
||||
label_diff_side_by_side: 并排
|
||||
|
|
|
@ -551,7 +551,24 @@ p.percent {
|
|||
font-size: 12px;
|
||||
}
|
||||
.repositorytitle select{ width: 110px; height: 21px; }
|
||||
|
||||
.riviseRed {
|
||||
width:15px;
|
||||
height:15px;
|
||||
margin-right: 3px;
|
||||
background-color:#FF0000;
|
||||
filter:alpha(opacity=50); /* ie 有效*/
|
||||
-moz-opacity:0.5; /* Firefox 有效*/
|
||||
opacity: 0.5; /* 通用,其他浏览器 有效*/
|
||||
}
|
||||
.changeBlue {
|
||||
width:15px;
|
||||
height:15px;
|
||||
margin-right: 3px;
|
||||
background-color:#0000FF;
|
||||
filter:alpha(opacity=50); /* ie 有效*/
|
||||
-moz-opacity:0.5; /* Firefox 有效*/
|
||||
opacity: 0.5; /* 通用,其他浏览器 有效*/
|
||||
}
|
||||
|
||||
|
||||
/*导出*/
|
||||
|
|
Loading…
Reference in New Issue