diff --git a/app/models/bubble/scorable.rb b/app/models/bubble/scorable.rb index 579f8af8d..90df3b9e2 100644 --- a/app/models/bubble/scorable.rb +++ b/app/models/bubble/scorable.rb @@ -45,7 +45,7 @@ module Bubble::Scorable # We store this as log2 to tame the huge/tiny numbers we'd otherwise get # when activity is far from the reference date. days_diff = (activity_at - REFERENCE_DATE) / 1.day - Math.log2(score) + days_diff + Math.log2(1.0 + score) + days_diff end def last_scorable_activity_at diff --git a/test/models/bubble/scorable_test.rb b/test/models/bubble/scorable_test.rb index fc89c11c2..e55241b07 100644 --- a/test/models/bubble/scorable_test.rb +++ b/test/models/bubble/scorable_test.rb @@ -53,4 +53,13 @@ class Bubble::ScorableTest < ActiveSupport::TestCase assert_equal [ bubble_new, bubble_mid, bubble_old ], Bubble.where(id: [ bubble_old, bubble_mid, bubble_new ]).ordered_by_activity end end + + test "bubbles with no activity have a valid activity_score_order" do + bubble = Bubble.create! bucket: buckets(:writebook), creator: users(:kevin) + + bubble.rescore + + assert bubble.activity_score.zero? + assert_not bubble.activity_score_order.infinite? + end end