|
|
|
@ -337,7 +337,80 @@ module UserScoreHelper
|
|
|
|
|
:activity => activity, :file => file, :issue => issue, :level => level)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#====================================================================================================
|
|
|
|
|
def get_option_number(user,type)
|
|
|
|
|
option_number = OptionNumber.where("user_id = '#{user.id}' and score_type = '#{type}'");
|
|
|
|
|
if option_number.nil?
|
|
|
|
|
option_number = OptionNumber.new
|
|
|
|
|
option_number.user_id = user.id
|
|
|
|
|
option_number.score_type =type
|
|
|
|
|
end
|
|
|
|
|
option_number
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#更新分数
|
|
|
|
|
def update_score(option_number)
|
|
|
|
|
option_number.total_score = collaboration(option_number) + influence(option_number) + skill(option_number) + active(option_number)
|
|
|
|
|
option_number.save
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#协同得分
|
|
|
|
|
def collaboration(option_number)
|
|
|
|
|
option_number.memo * 2 + option_number.messages_for_issues + option_number.issues_status + option_number.replay_for_message + option_number.replay_for_memo
|
|
|
|
|
end
|
|
|
|
|
#影响力得分
|
|
|
|
|
def influence(option_number)
|
|
|
|
|
option_number.follow * 2
|
|
|
|
|
end
|
|
|
|
|
#技术得分
|
|
|
|
|
def skill(option_number)
|
|
|
|
|
option_number.praise_by_one * 4 + option_number.praise_by_two * 6 + option_number.praise_by_three * 8 - option_number.tread * 2 - option_number.tread_by_one * 2 - option_number.tread_by_two * 4 - option_number.tread_by_three * 6
|
|
|
|
|
end
|
|
|
|
|
#项目贡献得分
|
|
|
|
|
def active(option_number)
|
|
|
|
|
option_number.changeset * 4 + option_number.document * 4 + option_number.attachment * 4 + option_number.issue_done_ratio * 2 + option_number.post_issue * 4
|
|
|
|
|
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
|
|
|
|
|
update_score(option_number)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#更新对缺陷留言数
|
|
|
|
|
def update_messges_for_issue(user,type)
|
|
|
|
|
option_number = get_option_number(user,type)
|
|
|
|
|
option_number.messages_for_issues = Journal.includes(:user).where("user_id = '#{user.id}'").all.count
|
|
|
|
|
update_score(option_number)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#更新更改缺陷状态状态次数
|
|
|
|
|
def update_issues_status(user,type)
|
|
|
|
|
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
|
|
|
|
|
update_score(option_number)
|
|
|
|
|
end
|
|
|
|
|
#更新对留言的回复数量
|
|
|
|
|
def update_replay_for_message(user,type)
|
|
|
|
|
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
|
|
|
|
|
update_score(option_number)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#更新对帖子的回复数量
|
|
|
|
|
def update_replay_for_memo(user,type)
|
|
|
|
|
option_number = get_option_number(user,type)
|
|
|
|
|
option_number.replay_for_memo = Message.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").count
|
|
|
|
|
update_score(option_number)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#更新被关注的人数
|
|
|
|
|
def update_follow(user,type)
|
|
|
|
|
option_number = get_option_number(user,type)
|
|
|
|
|
option_number.follow = Watcher.includes(:watchable).where("watchable_type = 'Principal' and watchable_id = '#{user.id}'").count
|
|
|
|
|
update_score(option_number)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#更新踩别人帖子的数量
|
|
|
|
|
end
|
|
|
|
|