项目统计数小于0情况判断

This commit is contained in:
huang 2016-02-23 13:24:20 +08:00
parent 44f192e5a6
commit 90208e166f
5 changed files with 8 additions and 12 deletions

View File

@ -644,12 +644,7 @@ class Attachment < ActiveRecord::Base
def decrease_attchments_count
if self.container_type == "Project" && !self.project.project_score.nil?
attach_count = self.container.project_score.attach_num - 1
if attach_count < 0
self.container.project_score.update_attribute(:attach_num, 0)
else
self.container.project_score.update_attribute(:attach_num, attach_count)
end
self.container.project_score.update_attribute(:attach_num, attach_count < 0 ? 0 : attach_count)
end
end
end

View File

@ -184,7 +184,7 @@ class Issue < ActiveRecord::Base
def decrease_issues_count
unless self.project.project_score.nil?
issue_count = self.project.project_score.issue_num - 1
self.project.project_score.update_attribute(:issue_num, issue_count)
self.project.project_score.update_attribute(:issue_num, issue_count < 0 ? 0 : issue_count)
end
end

View File

@ -219,8 +219,9 @@ class Journal < ActiveRecord::Base
# 减少留言数量统计
def decrease_issues_journal_count
unless self.issue.project.nil?
project = self.issue.project
project.project_score.update_attribute(:issue_journal_num, project.project_score.issue_journal_num - 1)
journal_count = self.issue.project.project_score.issue_journal_num - 1
# project = self.issue.project
self.issue.project.project_score.update_attribute(:issue_journal_num, journal_count < 0 ? 0 : journal_count)
end
end

View File

@ -146,10 +146,10 @@ class Message < ActiveRecord::Base
# 讨论区
if self.parent_id.nil?
count = self.project.project_score.board_num - 1
self.project.project_score.update_attribute(:board_num, count)
self.project.project_score.update_attribute(:board_num, count < 0 ? 0 : count)
else # 回复
count = self.project.project_score.board_message_num - 1
self.project.project_score.update_attribute(:board_message_num, count)
self.project.project_score.update_attribute(:board_message_num, count < 0 ? 0 : count)
end
end
end

View File

@ -126,7 +126,7 @@ class News < ActiveRecord::Base
def decrease_news_count
if self.project && !self.project.project_score.nil?
count = self.project.project_score.news_num - 1
self.project.project_score.update_attribute(:news_num, count)
self.project.project_score.update_attribute(:news_num, count < 0 ? 0 : count)
end
end