diff --git a/app/helpers/user_score_helper.rb b/app/helpers/user_score_helper.rb index 4dc4d4c6e..4c9a126f7 100644 --- a/app/helpers/user_score_helper.rb +++ b/app/helpers/user_score_helper.rb @@ -24,7 +24,28 @@ module UserScoreHelper issues.each do |issue| issue_c = issue_c + issue.journals.where("user_id <> ?", user.id).count end - issue_c = issue_c + Journal.where("user_id = ?", user.id) + issue_c = issue_c + Journal.where("user_id = ?", user.id).count + ############################ + memos = Memo.where('author_id = ? AND parent_id IS NOT NULL', user.id) + + memos.each do |m| + if Memo.find(m.parent_id).author.id != user.id + issue_c = issue_c + 1 + else + issue_c = issue_c - 1 + end + end + + + pmemos = Memo.where('author_id = ? AND parent_id IS NULL', user.id) + pmemos.each do |pm| + issue_c = issue_c + pm.replies_count + end + ############################ + + issue_c = issue_c + JournalsForMessage.where('user_id = ? AND reply_id IS NOT NULL AND reply_id <> ?', user.id, user.id).count + JournalsForMessage.where('reply_id = ? AND user_id <> ?', user.id, user.id).count + + return issue_c end @@ -91,7 +112,7 @@ module UserScoreHelper - tread_user_count = PraiseTread.where('praise_or_tread = ?, user_id = ?', 0, user.id).count + tread_user_count = PraiseTread.where('praise_or_tread = ? AND user_id = ?', 0, user.id).count skill_score = skill_score - 0.5 * tread_user_count @@ -139,13 +160,24 @@ module UserScoreHelper best_answer_num = 0 + isManager = 0 + members = Member.where('user_id = ?', user.id) + members.each do |m| + roles = m.member_roles + roles.each do |r| + if r.role_id == 3 + isManager = 1 + end + end + end + level = 0 if max_praise_num > 4 level = 1 elseif commit_count > 0 and commit_count < 101 level = 1 - elseif commit_count > 100 + elseif commit_count > 100 or isManager == 1 level = 2 end diff --git a/app/views/test/index.html.erb b/app/views/test/index.html.erb index 93225f513..43101bb4f 100644 --- a/app/views/test/index.html.erb +++ b/app/views/test/index.html.erb @@ -1,12 +1,16 @@