优化项目消息更新代码

This commit is contained in:
huang 2016-03-22 10:48:37 +08:00
parent e20fe85ddf
commit 341308658d
1 changed files with 3 additions and 12 deletions

View File

@ -560,18 +560,9 @@ class ProjectsController < ApplicationController
end
def update_message_status(user, project)
project_invite_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type =?", user, project, "ProjectInvite")
project_invite_messages.each do |project_invite_message|
project_invite_message.update_attribute(:viewed, true)
end
#更新被加入项目消息的viewed字段
join_project_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type=?", user, project, "JoinProject")
join_project_messages.each do |join_project|
join_project.update_attribute(:viewed, true)
end
#更新被移出项目消息的viewed字段
remove_project_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type=?", user, project, "RemoveFromProject")
remove_project_messages.update_all(:viewed => true)
# 更新加入项目消息
project__messages = ForgeMessage.where("forge_message_type in ('ProjectInvite', 'JoinProject', 'RemoveFromProject') and user_id =? and project_id =? ", user, project)
project__messages.update_all(:viewed => true) unless project__messages.blank?
end
def message_invite(message_id, key)