From ded3da6670bde0d1ef19586bf5f89f82659b9576 Mon Sep 17 00:00:00 2001 From: Wen Date: Tue, 22 Apr 2014 09:54:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=AF=84=E5=88=86=E7=90=86?= =?UTF-8?q?=E8=AE=BA=E4=B8=8A=E5=AE=8C=E6=88=90=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/user_score_helper.rb | 38 +++++++++++++++++++++++++++++--- app/views/test/index.html.erb | 16 +++++++++----- 2 files changed, 45 insertions(+), 9 deletions(-) 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 @@

test

-<% PraiseTreadCache.where('object_id = 47').each do |p| %> + +<% memos=Memo.where('author_id = 5 AND parent_id IS NOT NULL') %> +<% memos.each do |m|%> + - <%if p.praise_num < 0 or p.praise_num == 2%> - <%= p.praise_num %> - <%end%> - - + <% if Memo.find(m.parent_id).author_id != 5 %> + <%=m.subject%> + <% end %> +> + <% end %> +