From e33146813d260db65ddfd1a985ed31562e43a283 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Tue, 15 Nov 2016 09:25:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E6=97=A5=E5=BF=97=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/message.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/app/models/message.rb b/app/models/message.rb index 1d76c8ef6..6b2e29428 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -147,6 +147,7 @@ class Message < ActiveRecord::Base # 删除帖子的时候更新帖子总数, 删除回复的时候总数不减少 def decrease_boards_count + tStarttime = Time.now if self.project && !project.project_score.nil? # 讨论区 if self.parent_id.nil? @@ -157,13 +158,22 @@ class Message < ActiveRecord::Base self.project.project_score.update_attribute(:board_message_num, count < 0 ? 0 : count) end end + + tEndtime = Time.now + tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000 + logger.info "message_time decrease_boards_count! user wait time = #{tUsedtime} ms" end def reset_counters! + tStarttime = Time.now if parent && parent.id Message.update_all({:last_reply_id => parent.children.maximum(:id)}, {:id => parent.id}) end board.reset_counters! + + tEndtime = Time.now + tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000 + logger.info "message_time reset_counters! user wait time = #{tUsedtime} ms" end def sticky=(arg) @@ -358,6 +368,7 @@ class Message < ActiveRecord::Base #减少用户分数 def down_user_score + tStarttime = Time.now if self.parent_id.nil? && !self.board.project.nil? UserScore.joint(:delete_message, self.author,nil,self, { message_id: self.id }) update_memo_number(User.current,1) @@ -371,6 +382,10 @@ class Message < ActiveRecord::Base update_replay_for_memo(self.author,2,self.board.project) end end + + tEndtime = Time.now + tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000 + logger.info "message_time down_user_score! user wait time = #{tUsedtime} ms" end def send_mail @@ -381,7 +396,13 @@ class Message < ActiveRecord::Base # Author lizanle # Description 删除对应消息的图片资源 def delete_kindeditor_assets + tStarttime = Time.now + delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MESSAGE + + tEndtime = Time.now + tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000 + logger.info "message_time delete_kindeditor_assets! user wait time = #{tUsedtime} ms" end # 课程成员得分(活跃度) @@ -399,6 +420,7 @@ class Message < ActiveRecord::Base # 删除帖子的时候更新课程帖子总数, 删除回复的时候减少总数 def down_course_score + tStarttime = Time.now if self.course if self.parent_id.nil? # 发帖 down_course_score_num(self.course.id, self.author_id, "Message") @@ -407,6 +429,9 @@ class Message < ActiveRecord::Base down_course_score_num(self.course.id, self.author_id, "MessageReply") end end + tEndtime = Time.now + tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000 + logger.info "message_time down_course_score! user wait time = #{tUsedtime} ms" end def delete_org_activities