mirror of
https://github.com/discourse/discourse.git
synced 2025-03-22 23:15:53 +08:00
FIX: Bots accuracy should be zero (#8654)
This commit is contained in:
parent
b60b57cddd
commit
98853b217f
@ -62,7 +62,7 @@ class ReviewableScore < ActiveRecord::Base
|
|||||||
# if > 5 flags => (agreed flags / total flags) * 5.0
|
# if > 5 flags => (agreed flags / total flags) * 5.0
|
||||||
def self.user_accuracy_bonus(user)
|
def self.user_accuracy_bonus(user)
|
||||||
user_stat = user&.user_stat
|
user_stat = user&.user_stat
|
||||||
return 0.0 if user_stat.blank?
|
return 0.0 if user_stat.blank? || user.bot?
|
||||||
|
|
||||||
calc_user_accuracy_bonus(user_stat.flags_agreed, user_stat.flags_disagreed)
|
calc_user_accuracy_bonus(user_stat.flags_agreed, user_stat.flags_disagreed)
|
||||||
end
|
end
|
||||||
|
@ -96,6 +96,16 @@ RSpec.describe ReviewableScore, type: :model do
|
|||||||
expect(ReviewableScore.user_accuracy_bonus(user)).to eq(0.0)
|
expect(ReviewableScore.user_accuracy_bonus(user)).to eq(0.0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns 0 for a user with no flags" do
|
||||||
|
system_user = Discourse.system_user
|
||||||
|
stats = system_user.user_stat
|
||||||
|
|
||||||
|
stats.flags_agreed = 10
|
||||||
|
stats.flags_disagreed = 42
|
||||||
|
|
||||||
|
expect(ReviewableScore.user_accuracy_bonus(system_user)).to eq(0.0)
|
||||||
|
end
|
||||||
|
|
||||||
it "returns 0 until the user has made more than 5 flags" do
|
it "returns 0 until the user has made more than 5 flags" do
|
||||||
user_stat.flags_agreed = 4
|
user_stat.flags_agreed = 4
|
||||||
user_stat.flags_disagreed = 1
|
user_stat.flags_disagreed = 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user