This commit is contained in:
cxt 2016-01-14 16:58:51 +08:00
commit 7b4b575240
3 changed files with 26 additions and 30 deletions

View File

@ -90,7 +90,7 @@ class Attachment < ActiveRecord::Base
before_save :files_to_final_location,:act_as_course_activity 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_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_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 # add by nwb
# 获取所有可公开的资源文件列表 # 获取所有可公开的资源文件列表
@ -641,12 +641,12 @@ class Attachment < ActiveRecord::Base
end end
end end
# def decrease_attchments_count def decrease_attchments_count
# if self.container_type == "Project" if self.container_type == "Project" && !self.project.project_score.nil?
# count = self.container.attachments_count aatach_count = self.container.project_score.attach_num - 1+
# #self.container.update_attribute(:attachments_count, self.container.attachments_count - 1) self.container.project_score.update_attribute(:attach_num, aatach_count)
# end end
# end end
end end
# Delete the previous articles index in Elasticsearch # Delete the previous articles index in Elasticsearch

View File

@ -219,15 +219,15 @@ class Journal < ActiveRecord::Base
def decrease_issues_journal_count def decrease_issues_journal_count
unless self.issue.project.nil? unless self.issue.project.nil?
project = self.issue.project 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
end end
# issue留言总数更新 # issue留言总数更新
def add_journals_count 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 = 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 end
end end

View File

@ -128,8 +128,7 @@ class Message < ActiveRecord::Base
# 发帖精辟更新发帖总数 # 发帖精辟更新发帖总数
def add_boards_count def add_boards_count
unless self.project.project_score.nil? if self.project && !project.project_score.nil?
if self.project
# 讨论区 # 讨论区
if self.parent_id.nil? if self.parent_id.nil?
count = self.project.project_score.board_num + 1 count = self.project.project_score.board_num + 1
@ -140,12 +139,10 @@ class Message < ActiveRecord::Base
end end
end end
end end
end
# 删除帖子的时候更新帖子总数, 删除回复的时候总数不减少 # 删除帖子的时候更新帖子总数, 删除回复的时候总数不减少
def decrease_boards_count def decrease_boards_count
unless self.project.project_score.nil? if self.project && !project.project_score.nil?
if self.project && self.parent_id.nil?
# 讨论区 # 讨论区
if self.parent_id.nil? if self.parent_id.nil?
count = self.project.project_score.board_num - 1 count = self.project.project_score.board_num - 1
@ -156,7 +153,6 @@ class Message < ActiveRecord::Base
end end
end end
end end
end
def reset_counters! def reset_counters!
if parent && parent.id if parent && parent.id