diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 4fcb43172..4b7820037 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -49,6 +49,12 @@ module ApplicationHelper
end
end
+ # 获取项目/课程总分
+ # 发布缺陷 4分 回复缺陷 1分 提交一次 4分 讨论帖子 2分 回复帖子 1分 发布新闻 1分
+ def static_project_score obj
+ score = obj.issues_count * 4 + obj.journals_count + obj.commits_count * 4 + obj.boards_count * 2 + obj.boards_reply_count + obj.news_count
+ end
+
# 获取组织成员中文名字
def get_org_member_role_name member
case member.roles[0].name
diff --git a/app/models/message.rb b/app/models/message.rb
index c43657aa5..a133ecdfc 100644
--- a/app/models/message.rb
+++ b/app/models/message.rb
@@ -127,9 +127,15 @@ class Message < ActiveRecord::Base
# 发帖精辟更新发帖总数
def add_boards_count
- if self.project && self.parent_id.nil?
- count = self.project.boards_count + 1
- self.project.update_attribute(:boards_count, count)
+ if self.project
+ # 讨论区
+ if self.parent_id.nil?
+ count = self.project.boards_count + 1
+ self.project.update_attribute(:boards_count, count)
+ else # 回复
+ count = self.project.boards_reply_count + 1
+ self.project.update_attribute(:boards_reply_count, count)
+ end
end
end
@@ -314,8 +320,14 @@ class Message < ActiveRecord::Base
# 删除帖子的时候更新帖子总数, 删除回复的时候总数不减少
def decrease_boards_count
if self.project && self.parent_id.nil?
- count = self.project.boards_count - 1
- self.project.update_attribute(:boards_count, count)
+ # 讨论区
+ if self.parent_id.nil?
+ count = self.project.boards_count - 1
+ self.project.update_attribute(:boards_count, count)
+ else # 回复
+ count = self.project.boards_reply_count - 1
+ self.project.update_attribute(:boards_reply_count, count)
+ end
end
end
diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb
index 8bee1b7e2..8ecc6fb54 100644
--- a/app/views/layouts/base_projects.html.erb
+++ b/app/views/layouts/base_projects.html.erb
@@ -76,12 +76,13 @@
<% if @project.project_type == 0 %>
- <% unless project_scores(@project) == 0 %>
+ <% unless static_project_score(@project) == 0 %>
<%= l(:label_project_score)%> :
- <%= link_to(format("%.2f" ,project_scores(@project) ).to_i, {:controller => 'projects',
- :action => 'show_projects_score',
- :remote => true,
- :id => @project.id}, :class => "c_orange f14" ) %>
+ <%= link_to(format("%.2f" ,static_project_score(@project) ).to_i,
+ {:controller => 'projects',
+ :action => 'show_projects_score',
+ :remote => true,
+ :id => @project.id}, :class => "c_orange f14" ) %>
<% end %>
<% end %>
diff --git a/db/migrate/20160113063514_add_messages_count_to_project.rb b/db/migrate/20160113063514_add_messages_count_to_project.rb
new file mode 100644
index 000000000..218ac3cc4
--- /dev/null
+++ b/db/migrate/20160113063514_add_messages_count_to_project.rb
@@ -0,0 +1,5 @@
+class AddMessagesCountToProject < ActiveRecord::Migration
+ def change
+ add_column :projects, :boards_reply_count, :integer, :default => false
+ end
+end
diff --git a/db/migrate/20160113064153_statics_boards_reply.rb b/db/migrate/20160113064153_statics_boards_reply.rb
new file mode 100644
index 000000000..baf427b10
--- /dev/null
+++ b/db/migrate/20160113064153_statics_boards_reply.rb
@@ -0,0 +1,14 @@
+class StaticsBoardsReply < ActiveRecord::Migration
+ def up
+ Project.all.each do |project|
+ puts project.id
+ unless project.boards.first.nil?
+ messages_count = Message.where("board_id =? and parent_id is not ?", project.boards.first.id, nil).count
+ project.update_attribute(:boards_reply_count, messages_count)
+ end
+ end
+ end
+
+ def down
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index fc3762bd1..5079e6655 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20160108024752) do
+ActiveRecord::Schema.define(:version => 20160113064153) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@@ -1417,6 +1417,7 @@ ActiveRecord::Schema.define(:version => 20160108024752) do
t.integer "news_count", :default => 0
t.integer "acts_count", :default => 0
t.integer "journals_count", :default => 0
+ t.integer "boards_reply_count", :default => 0
end
add_index "projects", ["lft"], :name => "index_projects_on_lft"
diff --git a/public/stylesheets/scm.css b/public/stylesheets/scm.css
index 054b0bf99..b8b624154 100644
--- a/public/stylesheets/scm.css
+++ b/public/stylesheets/scm.css
@@ -52,6 +52,7 @@ table.filecontent th.line-num {
-ms-user-select: none;
-webkit-user-select: none;
font-weight:normal;
+ white-space: nowrap;
}
table.filecontent th.line-num a {
text-decoration: none;