|
|
|
@ -56,10 +56,18 @@ class UserScore < ActiveRecord::Base
|
|
|
|
|
user_score.collaboration = user_score.collaboration.to_i + 2
|
|
|
|
|
user_score.save
|
|
|
|
|
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a message. options => (#{options.to_s})"
|
|
|
|
|
when :delete_message # current_user 发帖了 Delete Message
|
|
|
|
|
user_score.collaboration = user_score.collaboration.to_i - 2
|
|
|
|
|
user_score.save
|
|
|
|
|
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a message. options => (#{options.to_s})"
|
|
|
|
|
when :post_issue # current_user 对 target_user 的缺陷留言了 Add Journal
|
|
|
|
|
user_score.collaboration = user_score.collaboration.to_i + 1
|
|
|
|
|
user_score.save
|
|
|
|
|
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a issue. options => (#{options.to_s})"
|
|
|
|
|
when :delete_issue # current_user 删除了 对 target_user 的缺陷留言了 Delete Journal
|
|
|
|
|
user_score.collaboration = user_score.collaboration.to_i - 1
|
|
|
|
|
user_score.save
|
|
|
|
|
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a issue. options => (#{options.to_s})"
|
|
|
|
|
when :change_issue_status # current_user 更改了缺陷的状态 Changed Issue
|
|
|
|
|
user_score.collaboration = user_score.collaboration.to_i + 1
|
|
|
|
|
user_score.save
|
|
|
|
@ -68,10 +76,18 @@ class UserScore < ActiveRecord::Base
|
|
|
|
|
user_score.collaboration = user_score.collaboration.to_i + 1
|
|
|
|
|
user_score.save
|
|
|
|
|
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply message. options => (#{options.to_s})"
|
|
|
|
|
when :reply_message_delete # current_user 删除了对 target_user 留言的回复 delete Journals_for_messages
|
|
|
|
|
user_score.collaboration = user_score.collaboration.to_i - 1
|
|
|
|
|
user_score.save
|
|
|
|
|
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} delete reply message. options => (#{options.to_s})"
|
|
|
|
|
when :reply_posting # current_user 对 target_user 帖子的回复 Add Message
|
|
|
|
|
user_score.collaboration = user_score.collaboration.to_i + 1
|
|
|
|
|
user_score.save
|
|
|
|
|
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply posting. options => (#{options.to_s})"
|
|
|
|
|
when :reply_deleting # current_user 删除了 对 target_user 帖子的回复 Delete Message
|
|
|
|
|
user_score.collaboration = user_score.collaboration.to_i - 1
|
|
|
|
|
user_score.save
|
|
|
|
|
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply deleting. options => (#{options.to_s})"
|
|
|
|
|
else
|
|
|
|
|
Rails.logger.error "[UserScore#joint] ===> #{operate} is not define."
|
|
|
|
|
return false
|
|
|
|
@ -95,19 +111,19 @@ class UserScore < ActiveRecord::Base
|
|
|
|
|
user_score = target_user.user_score_attr
|
|
|
|
|
case operate
|
|
|
|
|
when :followed_by # current_user 关注了target_user
|
|
|
|
|
user_score.active = user_score.influence.to_i + 2
|
|
|
|
|
user_score.influence = user_score.influence.to_i + 2
|
|
|
|
|
user_score.save
|
|
|
|
|
Rails.logger.info "[UserScore#influence] ===> User: #{current_user} be followed. options => (#{options.to_s})"
|
|
|
|
|
when :cancel_followed # current_uer 取消了对 target_user的关注
|
|
|
|
|
user_score.active = user_score.influence.to_i - 2
|
|
|
|
|
user_score.influence = user_score.influence.to_i - 2
|
|
|
|
|
user_score.save
|
|
|
|
|
Rails.logger.info "[UserScore#influence] ===> User: #{current_user} canceled followed. options => (#{options.to_s})"
|
|
|
|
|
else
|
|
|
|
|
Rails.logger.error "[UserScore#influence] ===> #{operate} is not define."
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
rescue => e
|
|
|
|
|
Rails.logger.error "[UserScore#influence] ===> Exception: #{e}."
|
|
|
|
|
#rescue => e
|
|
|
|
|
#Rails.logger.error "[UserScore#influence] ===> Exception: #{e}."
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 前略·技术得分
|
|
|
|
@ -122,13 +138,44 @@ class UserScore < ActiveRecord::Base
|
|
|
|
|
# Returns boolean. 返回积分保存结果
|
|
|
|
|
def self.skill(operate, current_user, target_user, options={})
|
|
|
|
|
current_user, target_user = get_users(current_user, target_user)
|
|
|
|
|
user_score = current_user.user_score_attr
|
|
|
|
|
current_user_score = current_user.user_score_attr
|
|
|
|
|
target_user_score = target_user.user_score_attr
|
|
|
|
|
case operate
|
|
|
|
|
# when :treading # current_user 踩了 target_user 的帖子
|
|
|
|
|
# Rails.logger.info "[UserScore#skill] ===> User: #{current_user} treading #{target_user}'s posting. options => (#{options.to_s})"
|
|
|
|
|
when :treaded_by_user # current_user 踩了 target_user 的帖子
|
|
|
|
|
when :treaded_by_user # current_user 踩了 target_user 的帖子
|
|
|
|
|
current_user_score.skill = current_user_score.skill.to_i - 2 #踩别人的帖子减2分
|
|
|
|
|
current_user_score.save
|
|
|
|
|
if current_user.id == target_user.id
|
|
|
|
|
target_user.reload
|
|
|
|
|
target_user_score = target_user.user_score_attr
|
|
|
|
|
end
|
|
|
|
|
level = current_user.get_level
|
|
|
|
|
if level == 1
|
|
|
|
|
target_user_score.skill = target_user_score.skill.to_i - 2 #帖子被一级会员踩-2分
|
|
|
|
|
target_user_score.save
|
|
|
|
|
elsif level == 2
|
|
|
|
|
target_user_score.skill = target_user_score.skill.to_i - 4 #帖子被二级会员踩-4分
|
|
|
|
|
target_user_score.save
|
|
|
|
|
elsif level == 3
|
|
|
|
|
target_user_score.skill = target_user_score.skill.to_i - 6 #帖子被三级会员踩-6分
|
|
|
|
|
target_user_score.save
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Rails.logger.info "[UserScore#skill] ===> User: #{current_user} treaded_by #{target_user}. options => (#{options.to_s})"
|
|
|
|
|
when :praised_by_user # current_user 顶了 target_user 的帖子
|
|
|
|
|
when :praised_by_user # current_user 顶了 target_user 的帖子
|
|
|
|
|
level = current_user.get_level
|
|
|
|
|
if level == 1
|
|
|
|
|
target_user_score.skill = target_user_score.skill.to_i + 4 #帖子被一级会员顶+4分
|
|
|
|
|
target_user_score.save
|
|
|
|
|
elsif level == 2
|
|
|
|
|
target_user_score.skill = target_user_score.skill.to_i + 6 #帖子被二级会员顶+6分
|
|
|
|
|
target_user_score.save
|
|
|
|
|
elsif level == 3
|
|
|
|
|
target_user_score.skill = target_user_score.skill.to_i + 8 #帖子被三级会员顶+8分
|
|
|
|
|
target_user_score.save
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
Rails.logger.info "[UserScore#skill] ===> User: #{current_user} praised_by #{target_user}. options => (#{options.to_s})"
|
|
|
|
|
else
|
|
|
|
|
Rails.logger.error "[UserScore#skill] ===> #{operate} is not define."
|
|
|
|
@ -194,17 +241,17 @@ class UserScore < ActiveRecord::Base
|
|
|
|
|
#分数小于0时修正为0
|
|
|
|
|
#分数大于等于0时不修正 -by zjc
|
|
|
|
|
def correct_score
|
|
|
|
|
if self.collaboration < 0
|
|
|
|
|
if !self.collaboration.nil? && self.collaboration < 0
|
|
|
|
|
self.collaboration = 0
|
|
|
|
|
end
|
|
|
|
|
if self.active < 0
|
|
|
|
|
self.active = 0
|
|
|
|
|
end
|
|
|
|
|
if self.influence < 0
|
|
|
|
|
if !self.influence.nil? && self.influence < 0
|
|
|
|
|
self.influence = 0
|
|
|
|
|
end
|
|
|
|
|
if self.skill < 0
|
|
|
|
|
if !self.skill.nil? && self.skill < 0
|
|
|
|
|
self.skill = 0
|
|
|
|
|
end
|
|
|
|
|
if !self.active.nil? && self.active < 0
|
|
|
|
|
self.active = 0
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|