Merge branch 'develop' into 'develop'
message 的delay job发送方式优化 See merge request !77
This commit is contained in:
commit
38659fc5a9
|
@ -328,19 +328,29 @@ class Message < ActiveRecord::Base
|
||||||
def delay_message_send
|
def delay_message_send
|
||||||
if self.course
|
if self.course
|
||||||
if self.parent_id.nil? # 发帖
|
if self.parent_id.nil? # 发帖
|
||||||
self.delay.contain_messages_message
|
dm = []
|
||||||
|
self.course.members.includes(:user).each do |m|
|
||||||
|
if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息
|
||||||
|
dm << {course_message_type:'Message',course_message_id:self.id, :user_id => m.user_id,
|
||||||
|
:course_id => self.board.course_id, :viewed => false}
|
||||||
|
if dm.size >= 30
|
||||||
|
self.delay.contain_messages_message(dm)
|
||||||
|
dm.clear
|
||||||
|
end
|
||||||
|
unless dm.empty?
|
||||||
|
self.delay.contain_messages_message(dm)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def contain_messages_message
|
|
||||||
self.course.members.includes(:user).each do |m|
|
|
||||||
if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息
|
|
||||||
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def contain_messages_message vs
|
||||||
|
CourseMessage.create(vs)
|
||||||
|
end
|
||||||
|
|
||||||
#更新用户分数 -by zjc
|
#更新用户分数 -by zjc
|
||||||
def be_user_score
|
def be_user_score
|
||||||
#新建message且无parent的为发帖
|
#新建message且无parent的为发帖
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
</li>
|
</li>
|
||||||
<li class="c_grey">
|
<li class="c_grey">
|
||||||
<% if !activity.assigned_to_id.nil? && activity.assigned_to_id != 0 %>
|
<% if !activity.assigned_to_id.nil? && activity.assigned_to_id != 0 %>
|
||||||
<% if activity.try(:assigned_to).try(:realname).empty? %>
|
<% if activity.try(:assigned_to).try(:realname).blank? %>
|
||||||
<%= link_to activity.assigned_to, user_path(activity.assigned_to_id)%>
|
<%= link_to activity.assigned_to, user_path(activity.assigned_to_id)%>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= link_to activity.try(:assigned_to).try(:realname), user_path(activity.assigned_to_id)%>
|
<%= link_to activity.try(:assigned_to).try(:realname), user_path(activity.assigned_to_id)%>
|
||||||
|
|
Loading…
Reference in New Issue