Merge branch 'guange_dev' into develop

This commit is contained in:
huang 2016-12-18 18:52:47 +08:00
commit 7a8eb84806
2 changed files with 31 additions and 12 deletions

View File

@ -33,12 +33,18 @@ class HomeworkCommonController < ApplicationController
@homeworks = paginateHelper @homework_commons,10
#设置at已读
@homeworks.each do |homework|
# homework.journals_for_messages.each do |j|
# User.current.at_messages.unviewed('JournalsForMessage', j.id).each {|x| x.viewed!}
# end
homework.delay.set_jour_viewed
ids = @homeworks.inject([]) do |ids, homework|
jids = homework.journals_for_messages.map(&:id)
jids ? ids + jids : ids
# homework.delay.set_jour_viewed
end
unless ids.empty?
User.current.at_messages.where(viewed: false,
at_message_type: 'JournalsForMessage',
at_message_id: ids).update_all(viewed: true)
end
@left_nav_type = 3
respond_to do |format|
format.js

View File

@ -208,16 +208,29 @@ class News < ActiveRecord::Base
def delay_news_send
if self.course
self.delay.contain_news_message
vs = []
self.course.members.each do | m|
if m.user_id != self.author_id
vs << {course_message_type:'News',course_message_id:self.id, :user_id => m.user_id,
:course_id => self.course_id, :viewed => false}
if vs.size >= 30
self.delay.contain_news_message(vs)
vs.clear
end
end
end
unless vs.empty?
self.delay.contain_news_message(vs)
end
end
end
def contain_news_message
self.course.members.each do |m|
if m.user_id != self.author_id
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false)
end
end
def contain_news_message(vs)
CourseMessage.create(vs)
end
# Time 2015-03-31 13:50:54