diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb index 88170dc2d..3446a86d4 100644 --- a/app/views/organizations/_org_course_homework.html.erb +++ b/app/views/organizations/_org_course_homework.html.erb @@ -190,10 +190,11 @@ <% else %> <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius",:id=>"project_img_"+project.id.to_s+"_"+activity.id.to_s,:alt =>"项目头像") %> <% end %> + <% com_time = project.project_score.commit_time %> <% time=project.updated_on %> <% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>

<%=(User.find project.user_id).show_name %>(组长)

-

<%=time_from_now time %>  <%= project.project_score.changeset_num %>提交

+

<%=time_from_now !com_time.nil? && format_time(com_time) > format_timetime ? com_time : time %>  <%= project.project_score.changeset_num %>提交

项目名称:<%=project.name %>
创建者:<%=(User.find project.user_id).show_name %>(组长)
diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index e6ed73036..5be1334c3 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -189,10 +189,11 @@ <% else %> <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius",:id=>"project_img_"+project.id.to_s+"_"+activity.id.to_s,:alt =>"项目头像") %> <% end %> + <% com_time = project.project_score.commit_time %> <% time=project.updated_on %> <% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>

<%=(User.find project.user_id).show_name %>(组长)

-

<%=time_from_now time %>  <%= project.project_score.changeset_num %>提交

+

<%=time_from_now !com_time.nil? && format_time(com_time) > format_timetime ? com_time : time %>  <%= project.project_score.changeset_num %>提交

项目名称:<%=project.name %>
创建者:<%=(User.find project.user_id).show_name %>(组长)
diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index bf24ea3b2..04c8b8f0a 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -156,7 +156,7 @@ <% break %> <% end %> <% end %> - <% if student_works > 5%> + <% if student_works.count > 5%> <%= link_to "更多>>", student_work_index_path(:homework => homework_common.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%> <% end %>
@@ -191,10 +191,11 @@ <% else %> <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius",:id=>"project_img_"+project.id.to_s+"_"+homework_common.id.to_s,:alt =>"项目头像") %> <% end %> + <% com_time = project.project_score.commit_time %> <% time=project.updated_on %> <% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>

<%=(User.find project.user_id).show_name %>(组长)

-

<%=time_from_now time %>  <%= project.project_score.changeset_num %>提交

+

<%=time_from_now !com_time.nil? && format_time(com_time) > format_timetime ? com_time : time %>  <%= project.project_score.changeset_num %>提交

项目名称:<%=project.name %>
创建者:<%=(User.find project.user_id).show_name %>(组长)
diff --git a/db/migrate/20160122023014_add_commit_time.rb b/db/migrate/20160122023014_add_commit_time.rb new file mode 100644 index 000000000..d9b860073 --- /dev/null +++ b/db/migrate/20160122023014_add_commit_time.rb @@ -0,0 +1,27 @@ +class AddCommitTime < ActiveRecord::Migration + def up + add_column :project_scores, :commit_time, :datetime, :default => nil + count = ProjectScore.all.count / 30 + 2 + transaction do + for i in 1 ... count do i + ProjectScore.page(i).per(30).each do |ps| + unless ps.project.nil? + unless ps.project.gpid.nil? + g = Gitlab.client + begin + changesets = g.commits(ps.project.gpid) + ps.commit_time = changesets[0].created_at + ps.save + rescue + logger.error("The project's rep is not exit!") + end + end + end + end + end + end + end + + def down + end +end