This commit is contained in:
chenmin 2014-08-18 17:44:48 +08:00
commit c042add122
12 changed files with 90 additions and 19 deletions

View File

@ -441,7 +441,7 @@ FROM `users` where id = #{user.id}")
#更新对缺陷留言数
def update_messges_for_issue(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
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
@ -464,7 +464,7 @@ FROM `users` where id = #{user.id}")
#更新更改缺陷状态状态次数
def update_issues_status(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
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
@ -490,7 +490,7 @@ FROM `users` where id = #{user.id}")
#更新对留言的回复数量
def update_replay_for_message(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
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
@ -514,7 +514,7 @@ FROM `users` where id = #{user.id}")
#更新对帖子的回复数量
def update_replay_for_memo(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
option_number.replay_for_memo = replay_for_memo_num(user,project)#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)
end
@ -552,7 +552,7 @@ FROM `users` where id = #{user.id}")
#更新帖子踩各项数量
def update_tread(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
tread_nums = tread_num(user,project)
option_number.tread = tread_nums[:tread]
option_number.tread_by_one = tread_nums[:tead_by_one]
@ -617,7 +617,7 @@ FROM `users` where id = #{user.id}")
#更新帖子顶数量
def update_praise(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
praise_nums = praise_num(user,project)
option_number.praise_by_one = praise_nums[:praise_by_one]
option_number.praise_by_two = praise_nums[:praise_by_two]
@ -682,7 +682,7 @@ FROM `users` where id = #{user.id}")
#更新提交代码次数
def update_changeset(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
option_number.changeset = changeset_num(user,project)#Changeset.includes(:user).where("user_id = '#{user.id}'").all.count
update_score(option_number)
end
@ -698,7 +698,7 @@ FROM `users` where id = #{user.id}")
#更新文档提交次数
def update_document(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
option_number.document = document_num(user,project)#Document.includes(:user).where("user_id = '#{user.id}'").all.count
update_score(option_number)
end
@ -714,7 +714,7 @@ FROM `users` where id = #{user.id}")
#更新附件提交数量
def update_attachment(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
option_number.attachment = attachment_num(user,project)#Attachment.includes(:author).where("author_id = '#{user.id}'").all.count
update_score(option_number)
end
@ -729,7 +729,7 @@ FROM `users` where id = #{user.id}")
#更新缺陷完成度次数
def update_issue_done_ratio(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
option_number.issue_done_ratio = issue_done_ratio_num(user,project) #Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'done_ratio' and #{User.table_name}.id = '#{user.id}'").count
update_score(option_number)
end
@ -745,7 +745,7 @@ FROM `users` where id = #{user.id}")
#更新发布缺陷次数
def update_post_issue(user,type,project=nil)
option_number = get_option_number(user,type)
option_number = get_option_number(user,type,project)
option_number.post_issue = post_issue_num(user,project) #Issue.includes(:author).where("author_id = '#{user.id}'").all.count
update_score(option_number)
end
@ -758,6 +758,12 @@ FROM `users` where id = #{user.id}")
end
end
#读取项目成员得分
def read_user_project_scores(user,project)
option_num = get_option_number(user,2,project)
option_num.total_score
end
def user_scores(user,type,project=nil)
ooption_num = get_option_number(user,type,project)
update_memo_number(user,type,project)

View File

@ -512,11 +512,18 @@ class Attachment < ActiveRecord::Base
end
end
update_attachment(self.author,1)
if self.container_type == 'Project'
update_attachment(self.author,2,self.container)
end
end
#删除附件时重新统计用户的附件数量得分
def down_user_score
update_attachment(self.author,1)
if self.container_type == 'Project'
update_attachment(self.author,2,self.container)
end
end
end

View File

@ -308,12 +308,14 @@ class Changeset < ActiveRecord::Base
#更新用户等级
UserLevels.update_user_level(self.user)
update_changeset(self.user,1)
update_changeset(self.user,2,self.repository.project)
end
#积分刷新
def down_user_score
UserLevels.update_user_level(self.user)
update_changeset(self.user,1)
update_changeset(self.user,2,self.repository.project)
end
end

View File

@ -69,9 +69,11 @@ class Document < ActiveRecord::Base
def be_user_score
UserScore.project(:push_document, self.user,self,{ document_id: self.id })
update_document(self.user,1)
update_document(self.user,2,self.project)
end
def down_user_score
update_document(self.user,1)
update_document(self.user,2,self.project)
end
end

View File

@ -1524,6 +1524,7 @@ class Issue < ActiveRecord::Base
def be_user_score_new_issue
UserScore.project(:post_issue, self.author,self, { issue_id: self.id })
update_post_issue(self.author,1)
update_post_issue(self.author,2,self.project)
end
def down_user_score
@ -1539,8 +1540,13 @@ class Issue < ActiveRecord::Base
# update_issues_status(self.author , 1)
#end
update_post_issue(self.author,1)
update_issue_done_ratio(User.current,1)
update_issues_status(self.author , 1)
#update_issue_done_ratio(self.author,1)
#update_issues_status(self.author , 1)
update_post_issue(self.author,2,self.project)
#update_issue_done_ratio(self.author,2,self.project)
#update_issues_status(self.author , 2)
end

View File

@ -163,6 +163,7 @@ class Journal < ActiveRecord::Base
#协同得分加分
UserScore.joint(:post_issue_message, self.user,self.issue.author,self, { message_id: self.id })
update_messges_for_issue(self.user,1)
update_messges_for_issue(self.user,2,self.issue.project)
end
end
@ -173,6 +174,7 @@ class Journal < ActiveRecord::Base
#协同得分减分
UserScore.joint(:delete_issue_message, self.user,self.issue.author,self, { message_id: self.id })
update_messges_for_issue(self.user,1)
update_messges_for_issue(self.user,2,self.issue.project)
end
end

View File

@ -46,9 +46,15 @@ class JournalDetail < ActiveRecord::Base
#更新缺陷完成度
if self.prop_key == 'done_ratio'
update_issue_done_ratio(self.journal.user,1)
unless self.journal.project.nil?
update_issue_done_ratio(self.journal.user,2,self.journal.project)
end
#更新缺陷状态
elsif self.prop_key == 'status_id'
update_issues_status(self.journal.user , 1)
unless self.journal.project.nil?
update_issues_status(self.journal.user,2,self.journal.project)
end
end
end
@ -57,9 +63,16 @@ class JournalDetail < ActiveRecord::Base
if self.prop_key == 'done_ratio'
update_issue_done_ratio(self.journal.user,1)
unless self.journal.project.nil?
update_issue_done_ratio(self.journal.user,2,self.journal.project)
end
#更新缺陷状态
elsif self.prop_key == 'status_id'
update_issues_status(self.journal.user, 1)
unless self.journal.project.nil?
update_issues_status(self.journal.user,2,self.journal.project)
end
end
end

View File

@ -144,6 +144,9 @@ class JournalsForMessage < ActiveRecord::Base
#协同得分加分
UserScore.joint(:reply_message, self.user,User.find(self.reply_id),self, { journals_for_messages_id: self.id })
update_replay_for_message(self.user,1)
if self.jour_type == "Project"
update_replay_for_message(self.user,2,self.jour)
end
end
end
# 更新用户分数 -by zjc
@ -153,6 +156,9 @@ class JournalsForMessage < ActiveRecord::Base
#协同得分减分
UserScore.joint(:reply_message_delete, self.user,User.find(self.reply_id), { journals_for_messages_id: self.id })
update_replay_for_message(self.user,1)
if self.jour_type == "Project"
update_replay_for_message(self.user,2,self.jour)
end
end
end
end

View File

@ -146,11 +146,12 @@ class Memo < ActiveRecord::Base
end
#更新用户分数 -by zjc
def be_user_score
def be_user_score
#新建memo且无parent的为发帖
if self.parent_id.nil?
UserScore.joint(:post_message, User.current,nil,self ,{ memo_id: self.id })
update_memo_number(User.current,1)
#新建memo且有parent的为回帖
elsif !self.parent_id.nil?
UserScore.joint(:reply_posting, User.current,self.parent.author,self, { memo_id: self.id })

View File

@ -152,11 +152,17 @@ class Message < ActiveRecord::Base
#新建message且无parent的为发帖
if self.parent_id.nil? && !self.board.project.nil?
UserScore.joint(:post_message, self.author,nil,self, { message_id: self.id })
update_memo_number(User.current,1)
update_memo_number(self.author,1)
if self.board.project_id != -1
update_memo_number(self.author,2,self.board.project)
end
#新建message且有parent的为回帖
elsif !self.parent_id.nil? && !self.board.project.nil?
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(self.author,1)
if self.board.project_id != -1
update_replay_for_memo(self.author,2,self.board.project)
end
end
end
@ -165,9 +171,15 @@ class Message < ActiveRecord::Base
if self.parent_id.nil? && !self.board.project.nil?
UserScore.joint(:delete_message, self.author,nil,self, { message_id: self.id })
update_memo_number(User.current,1)
if self.board.project_id != -1
update_memo_number(self.author,2,self.board.project)
end
elsif !self.parent_id.nil? && !self.board.project.nil?
UserScore.joint(:reply_deleting, self.author,self.parent.author,self, { message_id: self.id })
update_replay_for_memo(User.current,1)
if self.board.project_id != -1
update_replay_for_memo(self.author,2,self.board.project)
end
end
end
end

View File

@ -43,14 +43,21 @@ class PraiseTread < ActiveRecord::Base
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
target_user = obj.author
UserScore.skill(:treaded_by_user, User.current,target_user,self, { praise_tread_id: self.id })
update_tread(User.current,1)
update_tread(self.user,1)
update_tread(target_user,1)
unless self.project.nil?
update_tread(self.user,2,self.project)
update_tread(target_user,2,self.project)
end
#顶贴吧或讨论区帖子
elsif self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message')
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
target_user = obj.author
UserScore.skill(:praised_by_user, User.current,target_user,self,{ praise_tread_id: self.id })
update_praise(target_user,1)
unless self.project.nil?
update_praise(target_user,2,self.project)
end
#更新用户等级
UserLevels.update_user_level(target_user)
end
@ -62,14 +69,21 @@ class PraiseTread < ActiveRecord::Base
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
target_user = obj.author
#UserScore.skill(:treaded_by_user, User.current,target_user,self, { praise_tread_id: self.id })
update_tread(User.current,1)
update_tread(self.user,1)
update_tread(target_user,1)
unless self.project.nil?
update_tread(self.user,2,self.project)
update_tread(target_user,2,self.project)
end
#顶贴吧或讨论区帖子
elsif self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message')
obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id)
target_user = obj.author
#UserScore.skill(:praised_by_user, User.current,target_user,self,{ praise_tread_id: self.id })
update_praise(target_user,1)
unless self.project.nil?
update_praise(target_user,2,self.project)
end
#更新用户等级
UserLevels.update_user_level(target_user)
end

View File

@ -24,7 +24,7 @@
<%= content_tag "div", content_tag("p", rolesToLanguage(member.roles.sort.collect(&:to_s)).join(', ')), :class => "clear avatar_name" %>
<div class="clear avatar_user">
<p> <!--user_scores(member.user,2,@project).total_score).to_i UserGrade.find_by_user_id_and_project_id(member[:user_id], @project.id).grade).to_i-->
<%= l(:label_user_for_project_grade) %>: <span style="color:#ec6300"><%= format("%.2f" ,user_scores(member.user,2,@project).total_score).to_i %></span>
<%= l(:label_user_for_project_grade) %>: <span style="color:#ec6300"><%= format("%.2f" ,read_user_project_scores(member.user,@project)).to_i %></span>
</p>
</div>
<% end %>