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 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 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 diff --git a/app/views/projects/_code_submit_score_index.html.erb b/app/views/projects/_code_submit_score_index.html.erb index 802779967..70c0acbff 100644 --- a/app/views/projects/_code_submit_score_index.html.erb +++ b/app/views/projects/_code_submit_score_index.html.erb @@ -1,4 +1,4 @@ -
<%= l(:label_code_submit_number) %> * 4 = <%= changesets_num(@project) %> * 4 = <%= format("%.2f" , changesets_score(@project)).to_i %>
-
<%= l(:label_code_submit_score) %> = <%= format("%.2f" , changesets_score(@project)).to_i %>
+
<%= l(:label_code_submit_number) %> * 4 = <%= project.project_score.changeset_num %> * 4 = <%= project.project_score.changeset_num * 4 %>
+
<%= l(:label_code_submit_score) %> = <%= project.project_score.changeset_num * 4 %>
\ No newline at end of file diff --git a/app/views/projects/_file_score_index.html.erb b/app/views/projects/_file_score_index.html.erb index bfc87097e..645d6e264 100644 --- a/app/views/projects/_file_score_index.html.erb +++ b/app/views/projects/_file_score_index.html.erb @@ -1,4 +1,2 @@ - -
<%= l(:label_file_number) %> * 4 = <%= documents_num(@project) %> * 4 = <%= format("%.2f" , documents_score(@project)).to_i %>
-
<%= l(:label_file_score) %> = <%= format("%.2f" , documents_score(@project)).to_i %>
- \ No newline at end of file +
<%= l(:lable_file_attachment_number) %> * 5 = <%= project.project_score.attach_num %> * 5 = <%= project.project_score.attach_num * 5 %>
+
<%= l(:label_file_attachment_score) %> = <%= project.project_score.attach_num * 5 %>
diff --git a/app/views/projects/_issue_score_index.html.erb b/app/views/projects/_issue_score_index.html.erb index 729369280..d4e6688de 100644 --- a/app/views/projects/_issue_score_index.html.erb +++ b/app/views/projects/_issue_score_index.html.erb @@ -1,4 +1,4 @@ -
<%= l(:label_issue_number) %> * 4 = <%= issue_num(project) %> * 4 = <%= format("%.2f" , issue_num(project) * 4).to_i %>
-
<%= l(:label_issue_journal_number) %> * 1 = <%= issue_journal_num(project) %> * 1 = <%= format("%.2f" , issue_journal_num(project)).to_i %>
-
<%= l(:label_issue_score) %> = <%= format("%.2f" , issue_num(project) * 4).to_i %> + <%= format("%.2f" , issue_journal_num(project)).to_i %> - = <%= format("%.2f" , issue_score(project)).to_i %>
+
<%= l(:label_issue_number) %> * 4 = <%= issue_num(project) %> * 4 = <%= project.project_score.issue_num * 4 %>
+
<%= l(:label_issue_journal_number) %> * 1 = <%= project.project_score.issue_journal_num %> * 1 = <%= project.project_score.issue_journal_num * 1 %>
+
<%= l(:label_issue_score) %> = <%= project.project_score.issue_num * 4 %> + <%= project.project_score.issue_journal_num * 1 %> + = <%= @project.project_score.issue_num * 4 + @project.project_score.issue_journal_num %>
diff --git a/app/views/projects/_news_score_index.html.erb b/app/views/projects/_news_score_index.html.erb index c936ece05..a0587bdae 100644 --- a/app/views/projects/_news_score_index.html.erb +++ b/app/views/projects/_news_score_index.html.erb @@ -1,2 +1,2 @@ -
<%= l(:label_new_number) %> * 1 = <%= news_num(@project) %> * 1 = <%= format("%.2f" , news_score(@project)).to_i %>
-
<%= l(:label_news_score) %> = <%= format("%.2f" , news_score(@project)).to_i %>
\ No newline at end of file +
<%= l(:label_new_number) %> * 1 = <%= project.project_score.news_num %> * 1 = <%= project.project_score.news_num * 1 %>
+
<%= l(:label_news_score) %> = <%= project.project_score.news_num * 1 %>
\ No newline at end of file diff --git a/app/views/projects/_projects_topic_score_index.html.erb b/app/views/projects/_projects_topic_score_index.html.erb index 909f93a09..eea2c06c2 100644 --- a/app/views/projects/_projects_topic_score_index.html.erb +++ b/app/views/projects/_projects_topic_score_index.html.erb @@ -1,4 +1,4 @@ -
<%= l(:label_topic_number) %> * 2 = <%= board_message_num(@project) %> * 2 = <%= board_message_score(@project) %>
-
<%= l(:label_topic_score) %> = <%= format("%.2f" , board_message_score(@project)).to_i %>
+
<%= l(:label_topic_number) %> * 2 = <%= project.project_score.board_num %> * 2 = <%= project.project_score.board_num * 2 %>
+
<%= l(:label_topic_score) %> = <%= project.project_score.board_num * 2 %>
\ No newline at end of file diff --git a/app/views/projects/_show_projects_score.html.erb b/app/views/projects/_show_projects_score.html.erb index c18060257..203822f45 100644 --- a/app/views/projects/_show_projects_score.html.erb +++ b/app/views/projects/_show_projects_score.html.erb @@ -19,6 +19,36 @@ + +