diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 88d16162c..f81af7730 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1818,25 +1818,14 @@ class UsersController < ApplicationController def show if is_current_user # 自己的主页显示消息 - # 系统消息为管理员发送,我的消息中包含有系统消息 - @message_alls = [] - messages = MessageAll.where("(user_id =? and message_type !=?) or message_type =?" ,@user.id, "SystemMessage", "SystemMessage").includes(:message).order("created_at desc") - messages.each do |message_all| - mess = message_all.message - unless (message_all.message_type == 'CourseMessage' && mess && mess.course && mess.course.is_delete == 1) - @message_alls << mess - end - end + # 系统消息为管理员发送,我的消息中包含有系统消息(187ms) + @message_alls = MessageAll.where("(user_id =? and message_type !=?) or message_type =?" ,@user.id, "SystemMessage", "SystemMessage").includes(:message).order("created_at desc") @message_count = @message_alls.count @message_alls = paginateHelper @message_alls, 20 - # 用户待解决的issue -=begin - @unsolved_issues = Issue.where(:assigned_to_id => @user.id, :status_id => [1, 2, 4, 6]).includes(:author, :project).order("updated_on desc") - @unsolved_issues_count = @unsolved_issues.count - @unsolved_issue_pages = Paginator.new @unsolved_issues_count, 20, params['page'] || 1 - @unsolved_issues = paginateHelper @unsolved_issues, 20 -=end - @unsolved_issues_count = Issue.where(:assigned_to_id => @user.id, :status_id => [1, 2, 4, 6]).includes(:author, :project).order("updated_on desc").count + + # 待解决的issue数(1ms) + @unsolved_issues_count = Issue.find_by_sql("SELECT count(*) FROM `issues`, `projects` where issues.project_id = projects.id and projects.status =1 and assigned_to_id =#{@user.id} and status_id in (1, 2, 4, 6);").count + # 用户待完成的作业 my_course_ids = StudentsForCourse.where(:student_id => @user.id).blank? ? "(-1)" : "(" + StudentsForCourse.where(:student_id => @user.id).map{|sc| sc.course_id}.join(",") + ")" homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Date.today}'") diff --git a/app/views/users/_new_user_message.html.erb b/app/views/users/_new_user_message.html.erb index 511692ae5..46bf0ef7b 100644 --- a/app/views/users/_new_user_message.html.erb +++ b/app/views/users/_new_user_message.html.erb @@ -1,25 +1,25 @@ -<% message_alls.each do |ma| %> +<% @message_alls.each do |ma| %> <%# 系统消息 %> - <%= render :partial => 'users/user_message_system', :locals => {:ma => ma} %> + <%= render :partial => 'users/user_message_system', :locals => {:ma => ma.message} %> - <%= render :partial => 'users/user_at_message', :locals => {:ma => ma} %> + <%= render :partial => 'users/user_at_message', :locals => {:ma => ma.message} %> <%# 课程消息 %> - <%= render :partial => 'users/user_message_course', :locals => {:ma => ma} %> + <%= render :partial => 'users/user_message_course', :locals => {:ma => ma.message} %> - <%= render :partial => 'users/user_message_forge', :locals => {:ma => ma} %> + <%= render :partial => "users/user_message_forge", :locals => {:ma => ma.message} %> - <%= render :partial => 'users/user_message_forum', :locals => {:ma => ma} %> + <%= render :partial => 'users/user_message_forum', :locals => {:ma => ma.message} %> - <%= render :partial => 'users/user_message_userfeedaback', :locals => {:ma => ma} %> + <%= render :partial => 'users/user_message_userfeedaback', :locals => {:ma => ma.message} %> - <%= render :partial => 'users/user_message_org', :locals => {:ma => ma} %> + <%= render :partial => 'users/user_message_org', :locals => {:ma => ma.message} %> <%# 申请类消息 %> - <%= render :partial => 'users/user_message_applied', :locals => {:ma => ma} %> + <%= render :partial => 'users/user_message_applied', :locals => {:ma => ma.message} %> <% end %>