打分的调整
This commit is contained in:
parent
37304c1232
commit
90b53a7efb
|
@ -54,57 +54,111 @@ module UserScoreHelper
|
|||
watcher_count = Watcher.where("watchable_type = 'principal' AND watchable_id = ?", user.id).count
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
def calculate_skill_count(user)
|
||||
|
||||
praise_count = 0
|
||||
tread_count = 0
|
||||
praise_count_l0 = 0
|
||||
praise_count_l1 = 0
|
||||
praise_count_l2 = 0
|
||||
tread_count_l0 = 0
|
||||
tread_count_l1 = 0
|
||||
tread_count_l2 = 0
|
||||
issues = Issue.where('author_id = ?', user.id)
|
||||
issues.each do |i|
|
||||
ptcs = PraiseTreadCache.where('object_id = ?', i.id)
|
||||
ptcs.each do |p|
|
||||
praise_count = praise_count + p.praise_num.to_i
|
||||
tread_count = tread_count + p.tread_num.to_i
|
||||
pts = PraiseTread.where('praise_tread_object_id = ?', i.id)
|
||||
pts.each do |p|
|
||||
templevel = calculate_level(User.find(p.user_id))
|
||||
|
||||
if templevel.to_i == 0
|
||||
if p.praise_or_tread == 1
|
||||
praise_count_l0 = praise_count_l0 + 1
|
||||
else
|
||||
tread_count_l0 = tread_count_l0 + 1
|
||||
end
|
||||
end
|
||||
if templevel.to_i == 1
|
||||
if p.praise_or_tread == 1
|
||||
praise_count_l1 = praise_count_l1 + 1
|
||||
else
|
||||
tread_count_l1 = tread_count_l1 + 1
|
||||
end
|
||||
end
|
||||
if templevel.to_i == 2
|
||||
if p.praise_or_tread == 1
|
||||
praise_count_l2 = praise_count_l2 + 1
|
||||
else
|
||||
tread_count_l2 + tread_count_l2 + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
bids = Bid.where('author_id = ?', user.id)
|
||||
bids.each do |b|
|
||||
ptcs = PraiseTreadCache.where('object_id = ?', b.id)
|
||||
ptcs = PraiseTread.where('praise_tread_object_id = ?', b.id)
|
||||
ptcs.each do |p|
|
||||
praise_count = praise_count + p.praise_num.to_i
|
||||
tread_count = tread_count + p.tread_num.to_i
|
||||
templevel = calculate_level(User.find(p.user_id))
|
||||
|
||||
if templevel.to_i == 0
|
||||
if p.praise_or_tread == 1
|
||||
praise_count_l0 = praise_count_l0 + 1
|
||||
else
|
||||
tread_count_l0 = tread_count_l0 + 1
|
||||
end
|
||||
end
|
||||
if templevel.to_i == 1
|
||||
if p.praise_or_tread == 1
|
||||
praise_count_l1 = praise_count_l1 + 1
|
||||
else
|
||||
tread_count_l1 = tread_count_l1 + 1
|
||||
end
|
||||
end
|
||||
if templevel.to_i == 2
|
||||
if p.praise_or_tread == 1
|
||||
praise_count_l2 = praise_count_l2 + 1
|
||||
else
|
||||
tread_count_l2 + tread_count_l2 + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
contests = Contest.where('author_id = ?', user.id)
|
||||
contests.each do |c|
|
||||
ptcs = PraiseTreadCache.where('object_id = ?', c.id)
|
||||
ptcs = PraiseTread.where('praise_tread_object_id = ?', c.id)
|
||||
ptcs.each do |p|
|
||||
praise_count = praise_count + p.praise_num.to_i
|
||||
tread_count = tread_count + p.tread_num.to_i
|
||||
templevel = calculate_level(User.find(p.user_id))
|
||||
|
||||
if templevel.to_i == 0
|
||||
if p.praise_or_tread == 1
|
||||
praise_count_l0 = praise_count_l0 + 1
|
||||
else
|
||||
tread_count_l0 = tread_count_l0 + 1
|
||||
end
|
||||
end
|
||||
if templevel.to_i == 1
|
||||
if p.praise_or_tread == 1
|
||||
praise_count_l1 = praise_count_l1 + 1
|
||||
else
|
||||
tread_count_l1 = tread_count_l1 + 1
|
||||
end
|
||||
end
|
||||
if templevel.to_i == 2
|
||||
if p.praise_or_tread == 1
|
||||
praise_count_l2 = praise_count_l2 + 1
|
||||
else
|
||||
tread_count_l2 + tread_count_l2 + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
level = calculate_level(user)
|
||||
|
||||
skill_score = 0
|
||||
|
||||
if level == 0
|
||||
skill_score = praise_count - 2.5 * tread_count
|
||||
end
|
||||
if level == 1
|
||||
skill_score = 2 * praise_count - 1.5 * tread_count
|
||||
end
|
||||
if level == 2
|
||||
skill_socre = 3 * praise_count - 2.5 * tread_count
|
||||
end
|
||||
if level == 3
|
||||
skill_socre = 4 * praise_count - 3.5 * tread_count
|
||||
end
|
||||
if level == 4
|
||||
skill_socre = 5 * praise_count - 4.5 * tread_count
|
||||
end
|
||||
|
||||
# case level
|
||||
# when 0 skill_score = praise_count - 0.5 * tread_count
|
||||
|
@ -114,12 +168,19 @@ module UserScoreHelper
|
|||
# when 4 skill_socre = 5 * praise_count - 4.5 * tread_count
|
||||
# end
|
||||
|
||||
|
||||
skill_score = 2 * praise_count_l0.to_f + 3 * praise_count_l1.to_f + 4 * praise_count_l2.to_f
|
||||
- 1 * tread_count_l0.to_f - 1.5 * tread_count_l1.to_f - 2 * tread_count_l2.to_f
|
||||
|
||||
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.to_f - tread_user_count.to_f
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return skill_score
|
||||
|
||||
|
||||
|
|
|
@ -12,14 +12,13 @@
|
|||
|
||||
<tr>
|
||||
<td><%= user.lastname %><%= user.firstname %></td>
|
||||
<!-- <td><%= calculate_collaboration_count(user) %></td>
|
||||
<td><%= calculate_collaboration_count(user) %></td>
|
||||
<td><%= calculate_influence_count(user) %></td>
|
||||
<td><%= calculate_skill_count(user) %></td>
|
||||
<td><%= calculate_file(user) %></td>
|
||||
<td><%= calculate_issue(user) %></td>
|
||||
<td><%= calculate_level(user) %></td>-->
|
||||
<td><%= calculate_file(user) %></td>
|
||||
<td><%= calculate_issue(user) %></td>
|
||||
<td><%= calculate_level(user) %></td>
|
||||
|
||||
<td><%= user.changesets.count %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
|
Loading…
Reference in New Issue