parent
165d5f50c8
commit
05cf2d24dc
|
@ -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
|
||||
|
|
|
@ -127,9 +127,15 @@ class Message < ActiveRecord::Base
|
|||
|
||||
# 发帖精辟更新发帖总数
|
||||
def add_boards_count
|
||||
if self.project && self.parent_id.nil?
|
||||
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?
|
||||
# 讨论区
|
||||
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
|
||||
|
||||
|
|
|
@ -76,9 +76,10 @@
|
|||
<div class="cl"></div>
|
||||
<div>
|
||||
<% if @project.project_type == 0 %>
|
||||
<% unless project_scores(@project) == 0 %>
|
||||
<% unless static_project_score(@project) == 0 %>
|
||||
<span class="fb f14 "><%= l(:label_project_score)%> :</span>
|
||||
<%= link_to(format("%.2f" ,project_scores(@project) ).to_i, {:controller => 'projects',
|
||||
<%= 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" ) %>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddMessagesCountToProject < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :projects, :boards_reply_count, :integer, :default => false
|
||||
end
|
||||
end
|
|
@ -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
|
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue