用户评分理论上完成了

This commit is contained in:
Wen 2014-04-22 09:54:56 +08:00
parent dee5808407
commit ded3da6670
2 changed files with 45 additions and 9 deletions

View File

@ -24,7 +24,28 @@ module UserScoreHelper
issues.each do |issue| issues.each do |issue|
issue_c = issue_c + issue.journals.where("user_id <> ?", user.id).count issue_c = issue_c + issue.journals.where("user_id <> ?", user.id).count
end 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 return issue_c
end 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 skill_score = skill_score - 0.5 * tread_user_count
@ -139,13 +160,24 @@ module UserScoreHelper
best_answer_num = 0 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 level = 0
if max_praise_num > 4 if max_praise_num > 4
level = 1 level = 1
elseif commit_count > 0 and commit_count < 101 elseif commit_count > 0 and commit_count < 101
level = 1 level = 1
elseif commit_count > 100 elseif commit_count > 100 or isManager == 1
level = 2 level = 2
end end

View File

@ -1,12 +1,16 @@
<h3>test</h3> <h3>test</h3>
<% PraiseTreadCache.where('object_id = 47').each do |p| %>
<% memos=Memo.where('author_id = 5 AND parent_id IS NOT NULL') %>
<% memos.each do |m|%>
<tr> <tr>
<td><%if p.praise_num < 0 or p.praise_num == 2%> <% if Memo.find(m.parent_id).author_id != 5 %>
<%= p.praise_num %> <td><%=m.subject%></td>
<% end %> <% end %>
</td> </tr>>
</tr>
<% end %> <% end %>
<hr/> <hr/>
<hr/> <hr/>