From 286418b63cd5b3de79ad012ceee5ecb624d5bc1b Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 14 Jan 2016 15:42:27 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E8=AE=A8=E8=AE=BA=E5=8C=BA500=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/message.rb | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/app/models/message.rb b/app/models/message.rb index 618fb4659..675d37790 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -128,32 +128,28 @@ class Message < ActiveRecord::Base # 发帖精辟更新发帖总数 def add_boards_count - unless self.project.project_score.nil? - if self.project - # 讨论区 - if self.parent_id.nil? - count = self.project.project_score.board_num + 1 - self.project.project_score.update_attribute(:board_num, count) - else # 回复 - count = self.project.project_score.board_message_num + 1 - self.project.project_score.update_attribute(:board_message_num, count) - end + if self.project && !project.project_score.nil? + # 讨论区 + if self.parent_id.nil? + count = self.project.project_score.board_num + 1 + self.project.project_score.update_attribute(:board_num, count) + else # 回复 + count = self.project.project_score.board_message_num + 1 + self.project.project_score.update_attribute(:board_message_num, count) end end end # 删除帖子的时候更新帖子总数, 删除回复的时候总数不减少 def decrease_boards_count - unless self.project.project_score.nil? - if self.project && self.parent_id.nil? - # 讨论区 - if self.parent_id.nil? - count = self.project.project_score.board_num - 1 - self.project.project_score.update_attribute(:board_num, count) - else # 回复 - count = self.project.project_score.board_message_num - 1 - self.project.project_score.update_attribute(:board_message_num, count) - end + if self.project && !project.project_score.nil? + # 讨论区 + if self.parent_id.nil? + count = self.project.project_score.board_num - 1 + self.project.project_score.update_attribute(:board_num, count) + else # 回复 + count = self.project.project_score.board_message_num - 1 + self.project.project_score.update_attribute(:board_message_num, count) end end end From 01e8730b255b3c58847597583e8b5e129c10e04e Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 14 Jan 2016 15:52:14 +0800 Subject: [PATCH 2/3] =?UTF-8?q?issue=E5=9B=9E=E5=A4=8D=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=88=B0=E7=A7=AF=E5=88=86=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/journal.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/journal.rb b/app/models/journal.rb index 88b71d9ff..2da815a44 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -219,15 +219,15 @@ class Journal < ActiveRecord::Base def decrease_issues_journal_count unless self.issue.project.nil? project = self.issue.project - project.update_attribute(:journals_count, project.journals_count - 1) + project.project_score.update_attribute(:issue_journal_num, project.project_score.issue_journal_num - 1) end end # issue留言总数更新 def add_journals_count - if !self.issue.project.nil? && self.journalized_type == "Issue" && self.issue.project.project_score.nil? + if !self.issue.project.nil? && self.journalized_type == "Issue" && !self.issue.project.project_score.nil? project = self.issue.project - project.project_score.update_attribute(:issue_journal_num, project.project_score.journals_count + 1) + project.project_score.update_attribute(:issue_journal_num, project.project_score.issue_journal_num + 1) end end end From e9b54ad0121e806750feefe2f39a2d2adf28e8a9 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 14 Jan 2016 16:04:59 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E5=87=8F=E6=8E=89=E5=BE=97=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 3088714ee..2c99b6870 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -90,7 +90,7 @@ class Attachment < ActiveRecord::Base before_save :files_to_final_location,:act_as_course_activity after_create :office_conver, :be_user_score,:act_as_forge_activity,:create_attachment_ealasticsearch_index after_update :office_conver, :be_user_score,:update_attachment_ealasticsearch_index - after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index#, :decrease_attchments_count + after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index, :decrease_attchments_count # add by nwb # 获取所有可公开的资源文件列表 @@ -641,12 +641,12 @@ class Attachment < ActiveRecord::Base end end - # def decrease_attchments_count - # if self.container_type == "Project" - # count = self.container.attachments_count - # #self.container.update_attribute(:attachments_count, self.container.attachments_count - 1) - # end - # end + def decrease_attchments_count + if self.container_type == "Project" && !self.project.project_score.nil? + aatach_count = self.container.project_score.attach_num - 1+ + self.container.project_score.update_attribute(:attach_num, aatach_count) + end + end end # Delete the previous articles index in Elasticsearch