项目动态的更新时间更新到作业动态中

This commit is contained in:
cxt 2016-05-06 22:02:45 +08:00
parent 54cdd57f89
commit b8f7672424
5 changed files with 20 additions and 4 deletions

View File

@ -391,12 +391,17 @@ class HomeworkCommonController < ApplicationController
unless homeworks.nil?
homeworks.each do |h|
if h.homework_type == 3
student_works = h.student_works.where("project_id != 0")
student_works = h.student_work_projects.where("is_leader = 1")
time = h.updated_at
unless student_works.nil?
student_works.each do |s|
project = Project.find s.project_id
unless project.nil? && project.gpid.nil?
project_time=project.updated_on
project_time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last
if time < project_time
time = project_time
end
begin
# gitlab端获取默认分支
g = Gitlab.client

View File

@ -2960,6 +2960,14 @@ int main(int argc, char** argv){
return sort_projects
end
end
def project_sort_first projects
unless projects.empty?
project_ids = '('+projects.map{|pro|pro.project_id}.join(',')+')'
sort_projects = ForgeActivity.find_by_sql("SELECT updated_at,user_id, project_id FROM forge_activities WHERE project_id IN #{project_ids} ORDER BY updated_at DESC limit 1")
return sort_projects
end
end
end
def user_url_in_org(user_id)

View File

@ -182,7 +182,8 @@
<% sort_projects = project_sort_update projects %>
<div class="mt10 relatePWrap" id="relatePWrap_<%=user_activity_id %>">
<div class="mr5 fontGrey2">
#&nbsp;<%=time_from_now sort_projects.first.updated_at %><%= link_to User.find(sort_projects.first.user_id).show_name, user_activities_url_in_org(sort_projects.first.user_id), :class => "newsBlue ml5 mr5"%>更新了项目,最近更新:
<% first_pro = project_sort_first(projects).first %>
#&nbsp;<%=time_from_now first_pro.first.updated_at %><%= link_to User.find(first_pro.first.user_id).show_name, user_activities_url_in_org(first_pro.first.user_id), :class => "newsBlue ml5 mr5"%>更新了项目,最近更新:
</div>
<div class="cl"></div>
<% sort_projects.each_with_index do |pro, i| %>

View File

@ -191,7 +191,8 @@
<% sort_projects = project_sort_update projects %>
<div class="mt10 relatePWrap" id="relatePWrap_<%=user_activity_id %>">
<div class="mr5 fontGrey2">
#&nbsp;<%=time_from_now sort_projects.first.updated_at %><%= link_to User.find(sort_projects.first.user_id).show_name, user_activities_path(sort_projects.first.user_id), :class => "newsBlue ml5 mr5"%>更新了项目,最近更新:
<% first_pro = project_sort_first(projects).first %>
#&nbsp;<%=time_from_now first_pro.first.updated_at %><%= link_to User.find(first_pro.first.user_id).show_name, user_activities_path(first_pro.first.user_id), :class => "newsBlue ml5 mr5"%>更新了项目,最近更新:
</div>
<div class="cl"></div>
<% sort_projects.each_with_index do |pro, i| %>

View File

@ -196,7 +196,8 @@
<% sort_projects = project_sort_update projects %>
<div class="mt10 relatePWrap" id="relatePWrap_<%=homework_common.id %>">
<div class="mr5 fontGrey2">
#&nbsp;<%=time_from_now sort_projects.first.updated_at %><%= link_to User.find(sort_projects.first.user_id).show_name, user_activities_path(sort_projects.first.user_id), :class => "newsBlue ml5 mr5"%>更新了项目,最近更新:
<% first_pro = project_sort_first(projects).first %>
#&nbsp;<%=time_from_now first_pro.updated_at %><%= link_to User.find(first_pro.user_id).show_name, user_activities_path(first_pro.user_id), :class => "newsBlue ml5 mr5"%>更新了项目,最近更新:
</div>
<div class="cl"></div>
<% sort_projects.each_with_index do |pro, i| %>