FIX: Bots accuracy should be zero (#8654)

This commit is contained in:
Roman Rizzi 2020-01-02 13:24:24 -03:00 committed by GitHub
parent b60b57cddd
commit 98853b217f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -62,7 +62,7 @@ class ReviewableScore < ActiveRecord::Base
# if > 5 flags => (agreed flags / total flags) * 5.0
def self.user_accuracy_bonus(user)
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)
end

View File

@ -96,6 +96,16 @@ RSpec.describe ReviewableScore, type: :model do
expect(ReviewableScore.user_accuracy_bonus(user)).to eq(0.0)
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
user_stat.flags_agreed = 4
user_stat.flags_disagreed = 1