Merge pull request #568 from basecamp/fix-entropy-nil-error

Fix entropy nil error
This commit is contained in:
Jorge Manrubia
2025-06-02 18:05:19 +02:00
committed by GitHub
3 changed files with 26 additions and 4 deletions
+15 -3
View File
@@ -26,11 +26,19 @@ module Card::Entropy
end
def subject_to_entropy?
doing? || (auto_closing? && considering?)
auto_reconsidering? || auto_closing?
end
def auto_reconsidering?
doing? && last_active_at
end
def auto_closing?
considering? && collection.auto_closing? && last_active_at
end
def auto_close_at
last_active_at + auto_close_period if auto_closing? && last_active_at
last_active_at + auto_close_period if auto_closing?
end
def days_until_close
@@ -38,10 +46,14 @@ module Card::Entropy
end
def auto_reconsider_at
last_active_at + AUTO_RECONSIDER_PERIOD if last_active_at
last_active_at + AUTO_RECONSIDER_PERIOD if auto_reconsidering?
end
def days_until_reconsider
(auto_reconsider_at.to_date - Date.current).to_i if auto_reconsider_at
end
def entropy_cleaned_at
auto_close_at || auto_reconsider_at
end
end
@@ -1,7 +1,7 @@
<div hidden class="bubble bubble--<%= card.engagement_status %>"
data-controller="bubble" data-action="turbo:morph-element->bubble#update"
data-bubble-reminder-before-value="<%= Card::ENTROPY_REMINDER_BEFORE.in_days.to_i %>"
data-bubble-closes-at-value="<%= card.auto_close_at.iso8601 %>"
data-bubble-closes-at-value="<%= card.entropy_cleaned_at.iso8601 %>"
data-bubble-entropy-action-value="<%= card_entropy_action(card) %>">
<svg viewBox="0 0 200 100">
<path id="top-half" fill="transparent" d="M 20,100 A 80,80 0 0,1 180,100" />
+10
View File
@@ -47,4 +47,14 @@ class Card::EntropyTest < ActiveSupport::TestCase
assert cards(:logo).reload.considering?
assert_equal Time.current, cards(:logo).last_active_at
end
test "entropy_cleaned_at returns when the entropy will be cleaned" do
cards(:logo).reconsider
assert_equal cards(:logo).auto_close_at, cards(:logo).entropy_cleaned_at
assert_not_nil cards(:logo).entropy_cleaned_at
cards(:logo).engage
assert_equal cards(:logo).auto_reconsider_at, cards(:logo).entropy_cleaned_at
assert_not_nil cards(:logo).entropy_cleaned_at
end
end