部分私有的项目提交次数显示问题

This commit is contained in:
z9hang 2014-08-07 08:51:19 +08:00
parent c6271e2aa9
commit 17e6f0ee4f
2 changed files with 29 additions and 15 deletions

View File

@ -79,6 +79,9 @@ module ProjectScoreHelper
else
ps = pss.first
ps.grade = result
if ps.changesets_count.nil? || ps.changesets_count == ""
ps.changesets_count = project.changesets.count
end
ps.save
end
result

View File

@ -337,12 +337,15 @@ module UserScoreHelper
:activity => activity, :file => file, :issue => issue, :level => level)
end
#====================================================================================================
def get_option_number(user,type,project_id=nil)
if project_id.nil?
#========================================================================================================
#个人得分统计
#========================================================================================================
#type 1个人得分、2个人在项目project中的得分
def get_option_number(user,type,project=nil)
if project.nil?
option_number = OptionNumber.where("user_id = '#{user.id}' and score_type = '#{type}'");
else
option_number = OptionNumber.where("user_id = '#{user.id}' and score_type = '#{type}' and project_id = '#{project_id}'");
option_number = OptionNumber.where("user_id = '#{user.id}' and score_type = '#{type}' and project_id = '#{project.id}'");
end
result = nil
@ -402,9 +405,9 @@ module UserScoreHelper
end
#更新发帖数
def update_memo_number(user,type)
option_number = get_option_number(user,type)
option_number.memo = Message.includes(:author).where("parent_id IS NULL and author_id = '#{user.id}'").all.count + Memo.includes(:author).where("parent_id IS NULL and author_id = '#{user.id}'").all.count
def update_memo_number(user,type,project=nil)
option_number = get_option_number(user,type,project)
option_number.memo = memo_num(user,project)#Message.includes(:author).where("parent_id IS NULL and author_id = '#{user.id}'").all.count + Memo.includes(:author).where("parent_id IS NULL and author_id = '#{user.id}'").all.count
update_score(option_number)
end
@ -419,9 +422,9 @@ module UserScoreHelper
end
#更新对缺陷留言数
def update_messges_for_issue(user,type)
def update_messges_for_issue(user,type,project=nil)
option_number = get_option_number(user,type)
option_number.messages_for_issues = Journal.includes(:user).where("user_id = '#{user.id}' and notes != '' and notes is not null").all.count
option_number.messages_for_issues = messges_for_issue_num(user,project)#Journal.includes(:user).where("user_id = '#{user.id}' and notes != '' and notes is not null").all.count
update_score(option_number)
end
@ -434,9 +437,9 @@ module UserScoreHelper
end
#更新更改缺陷状态状态次数
def update_issues_status(user,type)
def update_issues_status(user,type,project=nil)
option_number = get_option_number(user,type)
option_number.issues_status = Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
option_number.issues_status = issues_status_num(user,project)#Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
update_score(option_number)
end
@ -450,14 +453,19 @@ module UserScoreHelper
end
#更新对留言的回复数量
def update_replay_for_message(user,type)
def update_replay_for_message(user,type,project=nil)
option_number = get_option_number(user,type)
option_number.replay_for_message = JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id}").count
option_number.replay_for_message = replay_for_message_num(user,project)#JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id}").count
update_score(option_number)
end
def replay_for_message_num(user)
#====================================contiue here=====================================================
def replay_for_message_num(user,project=nil)
if project.nil?
JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id}").count
else
end
end
#更新对帖子的回复数量
@ -727,6 +735,9 @@ module UserScoreHelper
else
Issue.includes(:author).where("author_id = '#{user.id}' and project_id = '#{project.id}'").all.count
end
end
def user_scores(user,type)
end
end