FIX: Sensitivity did not work by default

Forums without previously calculated scores would return the same values
for low/medium/high sensitivity. Now those are scaled based on the
default value.

The default value has also been changed from 10.0 to 12.5 based on
observing data from live discourse forums.
This commit is contained in:
Robin Ward
2019-09-19 13:17:00 -04:00
parent 7ad338e3e6
commit 3c6a5836c2
3 changed files with 34 additions and 23 deletions

View File

@ -78,6 +78,12 @@ class Reviewable < ActiveRecord::Base
)
end
# This number comes from looking at forums in the wild and what numbers work.
# As the site accumulates real data it'll be based on the site activity instead.
def self.typical_sensitivity
12.5
end
# Generate `pending?`, `rejected?`, etc helper methods
statuses.each do |name, id|
define_method("#{name}?") { status == id }
@ -195,11 +201,13 @@ class Reviewable < ActiveRecord::Base
return Float::MAX if sensitivity == 0
ratio = sensitivity / Reviewable.sensitivity[:low].to_f
high = PluginStore.get('reviewables', "priority_#{Reviewable.priorities[:high]}")
return (10.0 * scale) if high.nil?
high = (
PluginStore.get('reviewables', "priority_#{Reviewable.priorities[:high]}") ||
typical_sensitivity
).to_f
# We want this to be hard to reach
(high.to_f * ratio) * scale
((high.to_f * ratio) * scale).truncate(2)
end
def self.sensitivity_score(sensitivity, scale: 1.0)