得分机制修改

This commit is contained in:
z9hang 2014-07-29 18:04:35 +08:00
parent d8fcf8eb9b
commit c60188038e
8 changed files with 241 additions and 89 deletions

View File

@ -41,6 +41,7 @@ class UsersController < ApplicationController
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
:activity_new_score_index, :influence_new_score_index, :score_new_index] :activity_new_score_index, :influence_new_score_index, :score_new_index]
before_filter :auth_user_extension, only: :show before_filter :auth_user_extension, only: :show
before_filter :rest_user_score, only: :show
accept_api_auth :index, :show, :create, :update, :destroy,:tag_save , :tag_saveEx accept_api_auth :index, :show, :create, :update, :destroy,:tag_save , :tag_saveEx
#william #william
@ -54,6 +55,7 @@ class UsersController < ApplicationController
include AvatarHelper include AvatarHelper
include WordsHelper include WordsHelper
include GitlabHelper include GitlabHelper
include UserScoreHelper
# added by liuping 关注 # added by liuping 关注
@ -781,4 +783,17 @@ class UsersController < ApplicationController
redirect_to my_account_path redirect_to my_account_path
end end
end end
#重置用户得分
def rest_user_score
memo_num(@user)
messges_for_issue_num(@user)
issues_status_num(@user)
replay_for_memo_num(@user)
tread_num(@user)
praise_num(@user)
changeset_num(@user)
document_num(@user)
end
end end

View File

@ -410,7 +410,12 @@ module UserScoreHelper
#发帖数 #发帖数
def memo_num(user,project=nil) def memo_num(user,project=nil)
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 if project.nil?
Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id != -1").all.count
else
Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id = #{project.id}").all.count
end
end end
#更新对缺陷留言数 #更新对缺陷留言数
@ -421,7 +426,11 @@ module UserScoreHelper
end end
def messges_for_issue_num(user,project=nil) def messges_for_issue_num(user,project=nil)
Journal.includes(:user).where("user_id = '#{user.id}' and notes != '' and notes is not null").all.count if project.nil?
Journal.includes(:user).where("user_id = '#{user.id}' and notes != '' and notes is not null").all.count
else
Journal.includes(:user).joins(:issue).where("#{Journal.table_name}.user_id = '#{user.id}' and #{Issue.table_name}.project_id = '#{project.id}' and #{Journal.table_name}.notes != '' and #{Journal.table_name}.notes is not null").all.count
end
end end
#更新更改缺陷状态状态次数 #更新更改缺陷状态状态次数
@ -432,7 +441,12 @@ module UserScoreHelper
end end
def issues_status_num(user,project=nil) def issues_status_num(user,project=nil)
Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count if project.nil?
Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
else
Journal.joins(:issue,:details,:user).where("#{Issue.table_name}.project_id = '#{project.id}' and #{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
end
end end
#更新对留言的回复数量 #更新对留言的回复数量
@ -442,19 +456,23 @@ module UserScoreHelper
update_score(option_number) update_score(option_number)
end end
def replay_for_message_num(user,project=nil) def replay_for_message_num(user)
JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id}").count JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id}").count
end end
#更新对帖子的回复数量 #更新对帖子的回复数量
def update_replay_for_memo(user,type) def update_replay_for_memo(user,type)
option_number = get_option_number(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}").all.count + Memo.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count option_number.replay_for_memo = Message.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count #+ Memo.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count
update_score(option_number) update_score(option_number)
end end
def replay_for_memo_num(user,project=nil) def replay_for_memo_num(user,project=nil)
Message.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count + Memo.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count if project.nil?
Message.includes(:author).where("parent_id IS NOT NULL and author_id = #{user.id}").all.count
else
Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NOT NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id = #{project.id}").all.count
end
end end
#更新被关注的人数 #更新被关注的人数
@ -464,15 +482,15 @@ module UserScoreHelper
update_score(option_number) update_score(option_number)
end end
def follow_num(user,project=nil) def follow_num(user)
Watcher.includes(:watchable).where("watchable_type = 'Principal' and watchable_id = '#{user.id}'").count Watcher.includes(:watchable).where("watchable_type = 'Principal' and watchable_id = '#{user.id}'").count
end end
#更新帖子踩各项数量 #更新帖子踩各项数量
def update_tread(user,type) def update_tread(user,type)
option_number = get_option_number(user,type) option_number = get_option_number(user,type)
option_number.tread = PraiseTread.where("praise_tread_object_type = 'Memo' || praise_tread_object_type = 'Message' and praise_or_tread = 0 and user_id = '#{user.id}'").all.count option_number.tread = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0 and user_id = '#{user.id}'").all.count
pts = PraiseTread.where("praise_tread_object_type = 'Memo' || praise_tread_object_type = 'Message' and praise_or_tread = 0").all pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0").all
result = [] result = []
result1 = [] result1 = []
result2 = [] result2 = []
@ -499,34 +517,63 @@ module UserScoreHelper
end end
def tread_num(user,project=nil) def tread_num(user,project=nil)
result0 = PraiseTread.where("praise_tread_object_type = 'Memo' || praise_tread_object_type = 'Message' and praise_or_tread = 0 and user_id = '#{user.id}'").all.count if project.nil?
pts = PraiseTread.where("praise_tread_object_type = 'Memo' || praise_tread_object_type = 'Message' and praise_or_tread = 0").all result0 = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0 and user_id = '#{user.id}'").all.count
result = [] pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0").all
result1 = [] result = []
result2 = [] result1 = []
pts.each do |pt| result2 = []
obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id) pts.each do |pt|
if obj.nil? obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id)
next if obj.nil?
next
end
target_user = obj.author
level = UserLevels.get_level(pt.user)#pt.user.get_level
project = pt.project
if level == 1 && target_user.id = user.id
result << pt
elsif level == 2 && target_user.id = user.id
result1 << pt
elsif level == 3 && target_user.id = user.id
result2 << pt
end
end end
target_user = obj.author [:tread=>result0,:tead_by_one => result.count,:tread_by_two => result1.count,:tread_by_three =>result2.count]
level = UserLevels.get_level(pt.user)#pt.user.get_level else
project = pt.project result0 = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0 and user_id = '#{user.id}'").all.count
if level == 1 && target_user.id = user.id pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 0").all
result << pt result = []
elsif level == 2 && target_user.id = user.id result1 = []
result1 << pt result2 = []
elsif level == 3 && target_user.id = user.id pts.each do |pt|
result2 << pt obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id)
if obj.nil?
next
end
if !(pt.praise_tread_object_type == "Issue" && obj.project.id == project.id) && !(pt.praise_tread_object_type == "Message" && obj.board.project.id == project.id)
next
end
target_user = obj.author
level = UserLevels.get_level(pt.user)#pt.user.get_level
project = pt.project
if level == 1 && target_user.id = user.id
result << pt
elsif level == 2 && target_user.id = user.id
result1 << pt
elsif level == 3 && target_user.id = user.id
result2 << pt
end
end end
[:tread=>result0,:tead_by_one => result.count,:tread_by_two => result1.count,:tread_by_three =>result2.count]
end end
[:tread=>result0,:tead_by_one => result.count,:tread_by_two => result1.count,:tread_by_three =>result2.count]
end end
#更新帖子顶数量 #更新帖子顶数量
def update_praise(user,type) def update_praise(user,type)
option_number = get_option_number(user,type) option_number = get_option_number(user,type)
pts = PraiseTread.where("praise_tread_object_type = 'Memo' || praise_tread_object_type = 'Message' and praise_or_tread = 1").all pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 1").all
result = [] result = []
result1 = [] result1 = []
result2 = [] result2 = []
@ -553,27 +600,55 @@ module UserScoreHelper
end end
def praise_num(user,project=nil) def praise_num(user,project=nil)
pts = PraiseTread.where("praise_tread_object_type = 'Memo' || praise_tread_object_type = 'Message' and praise_or_tread = 1").all if project.nil?
result = [] pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 1").all
result1 = [] result = []
result2 = [] result1 = []
pts.each do |pt| result2 = []
obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id) pts.each do |pt|
if obj.nil? obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id)
next if obj.nil?
next
end
if !(pt.praise_tread_object_type == "Issue" && obj.project.id == project.id) && !(pt.praise_tread_object_type == "Message" && obj.board.project.id == project.id)
next
end
target_user = obj.author
level = UserLevels.get_level(pt.user)#pt.user.get_level
project = pt.project
if level == 1 && target_user.id = user.id
result << pt
elsif level == 2 && target_user.id = user.id
result1 << pt
elsif level == 3 && target_user.id = user.id
result2 << pt
end
end end
target_user = obj.author [:praise_by_one => result.count,:praise_by_two => result1.count,:praise_by_three => result2.count]
level = UserLevels.get_level(pt.user)#pt.user.get_level else
project = pt.project pts = PraiseTread.where("praise_tread_object_type = 'Issue' || praise_tread_object_type = 'Message' and praise_or_tread = 1").all
if level == 1 && target_user.id = user.id result = []
result << pt result1 = []
elsif level == 2 && target_user.id = user.id result2 = []
result1 << pt pts.each do |pt|
elsif level == 3 && target_user.id = user.id obj = PraiseTread.find_object_by_type_and_id(pt.praise_tread_object_type, pt.praise_tread_object_id)
result2 << pt if obj.nil?
next
end
target_user = obj.author
level = UserLevels.get_level(pt.user)#pt.user.get_level
project = pt.project
if level == 1 && target_user.id = user.id
result << pt
elsif level == 2 && target_user.id = user.id
result1 << pt
elsif level == 3 && target_user.id = user.id
result2 << pt
end
end end
[:praise_by_one => result.count,:praise_by_two => result1.count,:praise_by_three => result2.count]
end end
[:praise_by_one => result.count,:praise_by_two => result1.count,:praise_by_three => result2.count]
end end
#更新提交代码次数 #更新提交代码次数
@ -584,7 +659,12 @@ module UserScoreHelper
end end
def changeset_num(user,project=nil) def changeset_num(user,project=nil)
Changeset.includes(:user).where("user_id = '#{user.id}'").all.count if project.nil?
Changeset.includes(:user).where("user_id = '#{user.id}'").all.count
else
Changeset.includes(:user).joins(:repository).where("#{Changeset.table_name}.user_id = '#{user.id}' and #{Repository.table_name}.project_id = #{project.id}").all.count
end
end end
#更新文档提交次数 #更新文档提交次数
@ -594,8 +674,13 @@ module UserScoreHelper
update_score(option_number) update_score(option_number)
end end
def document(user,project=nil?) def document_num(user,project=nil?)
Document.includes(:user).where("user_id = '#{user.id}'").all.count if project.nil?
Document.includes(:user).where("user_id = '#{user.id}'").all.count
else
Document.includes(:user,:project).where("user_id = '#{user.id}' and project_id = '#{project.id}'").all.count
end
end end
#更新附件提交数量 #更新附件提交数量
@ -604,9 +689,14 @@ module UserScoreHelper
option_number.attachment = Attachment.includes(:author).where("author_id = '#{user.id}'").all.count option_number.attachment = Attachment.includes(:author).where("author_id = '#{user.id}'").all.count
update_score(option_number) update_score(option_number)
end end
#===================here to continue============================
def attachment_num(user,project=nil) def attachment_num(user,project=nil)
Attachment.includes(:author).where("author_id = '#{user.id}'").all.count if project.nil?
Attachment.includes(:author).where("author_id = '#{user.id}'").all.count
else
Attachment.includes(:author,:container).where("author_id = '#{user.id}' and container_type = 'Project' and container_id = #{project.id}").all.count
end
end end
#更新缺陷完成度次数 #更新缺陷完成度次数
@ -626,6 +716,7 @@ module UserScoreHelper
option_number.post_issue = Issue.includes(:author).where("author_id = '#{user.id}'").all.count option_number.post_issue = Issue.includes(:author).where("author_id = '#{user.id}'").all.count
update_score(option_number) update_score(option_number)
end end
def post_issue_num(user,project=nil) def post_issue_num(user,project=nil)
Issue.includes(:author).where("author_id = '#{user.id}'").all.count Issue.includes(:author).where("author_id = '#{user.id}'").all.count
end end

View File

@ -79,6 +79,7 @@ class Issue < ActiveRecord::Base
# fq # fq
after_create :act_as_activity,:be_user_score_new_issue after_create :act_as_activity,:be_user_score_new_issue
after_update :be_user_score after_update :be_user_score
before_destroy :down_user_score
# after_create :be_user_score # after_create :be_user_score
# end # end
@ -1524,5 +1525,19 @@ class Issue < ActiveRecord::Base
update_post_issue(self.author,1) update_post_issue(self.author,1)
end end
def down_user_score
#缺陷完成度更新
if self.done_ratio_changed?
UserScore.project(:update_issue_ratio, User.current,self,{ issue_id: self.id })
#update_issue_done_ratio(User.current,1)
end
#缺陷状态更改
if self.status_id_changed?
#协同得分
UserScore.joint(:change_issue_status, User.current,nil,self, {issue_id: self.id})
#update_issues_status(self.author , 1)
end
end
end end

View File

@ -48,9 +48,9 @@ class Journal < ActiveRecord::Base
# fq # fq
after_create :act_as_activity,:be_user_score after_create :act_as_activity,:be_user_score
# end # end
after_destroy :down_user_score #after_destroy :down_user_score
#before_save :be_user_score #before_save :be_user_score
#before_destroy :down_user_score before_destroy :down_user_score
scope :visible, lambda {|*args| scope :visible, lambda {|*args|
user = args.shift || User.current user = args.shift || User.current
@ -158,13 +158,20 @@ class Journal < ActiveRecord::Base
# 更新用户分数 -by zjc # 更新用户分数 -by zjc
def be_user_score def be_user_score
#新建了缺陷留言且留言不为空,不为空白
if !self.notes.nil? && self.notes.gsub(' ','') != ''
#协同得分加分 #协同得分加分
UserScore.joint(:post_issue_message, User.current,self.issue.author,self, { message_id: self.id }) UserScore.joint(:post_issue_message, self.user,self.issue.author,self, { message_id: self.id })
update_messges_for_issue(User.current,1) end
#update_messges_for_issue(User.current,1)
end end
# 减少用户分数 -by zjc # 减少用户分数 -by zjc
def down_user_score def down_user_score
#删除有效缺陷留言 #删除有效缺陷留言
update_messges_for_issue(User.current,1) if !self.notes.nil? && self.notes.gsub(' ','') != ''
#协同得分减分
UserScore.joint(:delete_issue_message, self.user,self.issue.author,self, { message_id: self.id })
end
#update_messges_for_issue(User.current,1)
end end
end end

View File

@ -20,7 +20,8 @@ class JournalDetail < ActiveRecord::Base
belongs_to :journal belongs_to :journal
before_save :normalize_values before_save :normalize_values
after_create :be_user_score after_create :be_user_score
after_destroy :down_user_score #after_destroy :down_user_score
before_destroy :down_user_score
private private
def normalize_values def normalize_values
@ -44,17 +45,24 @@ class JournalDetail < ActiveRecord::Base
def be_user_score def be_user_score
#更新缺陷完成度 #更新缺陷完成度
if self.prop_key == 'done_ratio' if self.prop_key == 'done_ratio'
update_issue_done_ratio(User.current,1) #update_issue_done_ratio(User.current,1)
#更新缺陷状态 #更新缺陷状态
elsif self.prop_key == 'status_id' elsif self.prop_key == 'status_id'
update_issues_status(User.current , 1) #update_issues_status(User.current , 1)
end end
end end
#更新用户分数 #更新用户分数
def down_user_score def down_user_score
update_issue_done_ratio(User.current,1) #update_issue_done_ratio(User.current,1)
update_issues_status(User.current , 1) #update_issues_status(User.current , 1)
if self.prop_key == 'done_ratio'
#更新缺陷状态
elsif self.prop_key == 'status_id'
UserScore.joint(:delete_issue_status, self.journal.user,nil,self, {issue_id: self.id})
end
end end
end end

View File

@ -42,9 +42,9 @@ class Memo < ActiveRecord::Base
"parent_id", "parent_id",
"replies_count" "replies_count"
after_create :add_author_as_watcher, :reset_counters!,:be_user_score after_create :add_author_as_watcher, :reset_counters!#,:be_user_score -- 公共区发帖暂不计入得分
# after_update :update_memos_forum # after_update :update_memos_forum
after_destroy :reset_counters!,:down_user_score after_destroy :reset_counters!#,:down_user_score -- 公共区发帖暂不计入得分
# after_create :send_notification # after_create :send_notification
# after_save :plusParentAndForum # after_save :plusParentAndForum
# after_destroy :minusParentAndForum # after_destroy :minusParentAndForum

View File

@ -59,12 +59,12 @@ class Message < ActiveRecord::Base
after_create :add_author_as_watcher, :reset_counters! after_create :add_author_as_watcher, :reset_counters!
after_update :update_messages_board after_update :update_messages_board
after_destroy :reset_counters!,:down_user_score after_destroy :reset_counters!#,:down_user_score
# fq # fq
after_create :act_as_activity,:be_user_score after_create :act_as_activity,:be_user_score
#before_save :be_user_score #before_save :be_user_score
#before_destroy :down_user_score before_destroy :down_user_score
# end # end
scope :visible, lambda {|*args| scope :visible, lambda {|*args|
@ -149,20 +149,24 @@ class Message < ActiveRecord::Base
#更新用户分数 -by zjc #更新用户分数 -by zjc
def be_user_score def be_user_score
#新建message且无parent的为发帖 #新建message且无parent的为发帖
if self.parent_id.nil? if self.parent_id.nil? && !self.board.project.nil?
UserScore.joint(:post_message, User.current,nil,self, { message_id: self.id }) UserScore.joint(:post_message, self.author,nil,self, { message_id: self.id })
update_memo_number(User.current,1) #update_memo_number(User.current,1)
#新建message且有parent的为回帖 #新建message且有parent的为回帖
elsif !self.parent_id.nil? elsif !self.parent_id.nil? && !self.board.project.nil?
UserScore.joint(:reply_posting, User.current,self.parent.author,self, { message_id: self.id }) UserScore.joint(:reply_posting, self.author,self.parent.author,self, { message_id: self.id })
update_replay_for_memo(User.current,1) #update_replay_for_memo(User.current,1)
end end
end end
#减少用户分数 #减少用户分数
def down_user_score def down_user_score
#更新发帖和回帖数量 if self.parent_id.nil? && !self.board.project.nil?
update_memo_number(User.current,1) UserScore.joint(:delete_message, self.author,nil,self, { message_id: self.id })
update_replay_for_memo(User.current,1) elsif !self.parent_id.nil? && !self.board.project.nil?
UserScore.joint(:reply_deleting, self.author,self.parent.author,self, { message_id: self.id })
end
#update_memo_number(User.current,1)
#update_replay_for_memo(User.current,1)
end end
end end

View File

@ -69,10 +69,11 @@ class UserScore < ActiveRecord::Base
end end
create_score_changed_details({:current_user_id => current_user.id ,:score_type => "collaboration",:score_action => "post_message",:user_id => current_user.id,:old_score => user_score.collaboration - 2,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) create_score_changed_details({:current_user_id => current_user.id ,:score_type => "collaboration",:score_action => "post_message",:user_id => current_user.id,:old_score => user_score.collaboration - 2,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a message. options => (#{options.to_s})" Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a message. options => (#{options.to_s})"
#when :delete_message # current_user 删帖了 Delete Message when :delete_message # current_user 删帖了 Delete Message
# user_score.collaboration = user_score.collaboration.to_i - 2 user_score.collaboration = user_score.collaboration.to_i - 2
# user_score.save user_score.save
# Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a message. options => (#{options.to_s})" create_score_changed_details({:current_user_id => current_user.id ,:score_type => "collaboration",:score_action => "post_message",:user_id => current_user.id,:old_score => user_score.collaboration + 2,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a message. options => (#{options.to_s})"
when :post_issue_message # current_user 对 target_user 的缺陷留言了 Add Journal when :post_issue_message # current_user 对 target_user 的缺陷留言了 Add Journal
user_score.collaboration = user_score.collaboration.to_i + 1 user_score.collaboration = user_score.collaboration.to_i + 1
user_score.save user_score.save
@ -81,11 +82,12 @@ class UserScore < ActiveRecord::Base
user_grade.save user_grade.save
end end
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "collaboration",:score_action => "post_issue_message",:user_id => current_user.id,:old_score => user_score.collaboration - 1,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "collaboration",:score_action => "post_issue_message",:user_id => current_user.id,:old_score => user_score.collaboration - 1,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a issue. options => (#{options.to_s})" Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a issue message. options => (#{options.to_s})"
#when :delete_issue_message # current_user 删除了 对 target_user 的缺陷留言了 Delete Journal when :delete_issue_message # current_user 删除了 对 target_user 的缺陷留言了 Delete Journal
# user_score.collaboration = user_score.collaboration.to_i - 1 user_score.collaboration = user_score.collaboration.to_i - 1
# user_score.save user_score.save
# Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a issue. options => (#{options.to_s})" create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "collaboration",:score_action => "delete_issue_message",:user_id => current_user.id,:old_score => user_score.collaboration + 1,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a issue message. options => (#{options.to_s})"
when :change_issue_status # current_user 更改了缺陷的状态 Changed Issue when :change_issue_status # current_user 更改了缺陷的状态 Changed Issue
user_score.collaboration = user_score.collaboration.to_i + 1 user_score.collaboration = user_score.collaboration.to_i + 1
user_score.save user_score.save
@ -95,6 +97,11 @@ class UserScore < ActiveRecord::Base
end end
create_score_changed_details({:current_user_id => current_user.id , :score_type => "collaboration",:score_action => "change_issue_status",:user_id => current_user.id,:old_score => user_score.collaboration - 1,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) create_score_changed_details({:current_user_id => current_user.id , :score_type => "collaboration",:score_action => "change_issue_status",:user_id => current_user.id,:old_score => user_score.collaboration - 1,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} change issue status. options => (#{options.to_s})" Rails.logger.info "[UserScore#joint] ===> User: #{current_user} change issue status. options => (#{options.to_s})"
when :delete_issue_status
user_score.collaboration = user_score.collaboration.to_i - 1
user_score.save
create_score_changed_details({:current_user_id => current_user.id , :score_type => "collaboration",:score_action => "delete_issue_status",:user_id => current_user.id,:old_score => user_score.collaboration + 1,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} delete issue status. options => (#{options.to_s})"
when :reply_message # current_user 对 target_user 留言的回复 Add Journals_for_messages when :reply_message # current_user 对 target_user 留言的回复 Add Journals_for_messages
user_score.collaboration = user_score.collaboration.to_i + 1 user_score.collaboration = user_score.collaboration.to_i + 1
user_score.save user_score.save
@ -117,10 +124,10 @@ class UserScore < ActiveRecord::Base
end end
create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "collaboration",:score_action => "reply_posting",:user_id => current_user.id,:old_score => user_score.collaboration - 1,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "collaboration",:score_action => "reply_posting",:user_id => current_user.id,:old_score => user_score.collaboration - 1,:new_score => user_score.collaboration,:current_user_level => UserLevels.get_level(current_user),:target_user_level => UserLevels.get_level(target_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply posting. options => (#{options.to_s})" Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply posting. options => (#{options.to_s})"
#when :reply_deleting # current_user 删除了 对 target_user 帖子的回复 Delete Message when :reply_deleting # current_user 删除了 对 target_user 帖子的回复 Delete Message
# user_score.collaboration = user_score.collaboration.to_i - 1 user_score.collaboration = user_score.collaboration.to_i - 1
# user_score.save user_score.save
# Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply deleting. options => (#{options.to_s})" Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply deleting. options => (#{options.to_s})"
else else
Rails.logger.error "[UserScore#joint] ===> #{operate} is not define." Rails.logger.error "[UserScore#joint] ===> #{operate} is not define."
return false return false
@ -329,6 +336,11 @@ class UserScore < ActiveRecord::Base
end end
create_score_changed_details({:current_user_id => current_user.id , :score_type => "active",:score_action => "update_issue_ratio",:user_id => current_user.id,:old_score => user_score.active - 2,:new_score => user_score.active,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) create_score_changed_details({:current_user_id => current_user.id , :score_type => "active",:score_action => "update_issue_ratio",:user_id => current_user.id,:old_score => user_score.active - 2,:new_score => user_score.active,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] updated issue ratio. options => (#{options.to_s})" Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] updated issue ratio. options => (#{options.to_s})"
when :delete_issue_ratio
user_score.active = user_score.active.to_i - 2
user_score.save
create_score_changed_details({:current_user_id => current_user.id , :score_type => "active",:score_action => "delete_issue_ratio",:user_id => current_user.id,:old_score => user_score.active + 2,:new_score => user_score.active,:current_user_level => UserLevels.get_level(current_user),:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s})
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] delete issue ratio. options => (#{options.to_s})"
when :post_issue # current_user 发布了缺陷 issue when :post_issue # current_user 发布了缺陷 issue
user_score.active = user_score.active.to_i + 4 user_score.active = user_score.active.to_i + 4
user_score.save user_score.save