Address PR feedback

This commit is contained in:
Andy Smith
2025-05-01 09:58:23 +02:00
parent 5eccad2659
commit 78941e5068
2 changed files with 7 additions and 8 deletions
+5 -6
View File
@@ -2,7 +2,7 @@ module Card::Closeable
extend ActiveSupport::Concern
AUTO_CLOSE_AFTER = 30.days
AUTO_CLOSE_REMINDER = 7.days
AUTO_CLOSE_REMINDER_BEFORE = 7.days
included do
has_one :closure, dependent: :destroy
@@ -26,13 +26,12 @@ module Card::Closeable
last_active_at + AUTO_CLOSE_AFTER if last_active_at
end
def auto_close_days_until
return false unless auto_close_at
(auto_close_at.to_date - Date.today).to_i
def days_until_close
(auto_close_at.to_date - Date.current).to_i if auto_close_at
end
def auto_close_remind?
auto_close_days_until <= AUTO_CLOSE_REMINDER / 1.day
def closing_soon?
considering? && Time.current >= auto_close_at - AUTO_CLOSE_REMINDER_BEFORE
end
def closed?
+2 -2
View File
@@ -23,8 +23,8 @@
<%= render "cards/display/common/background", card: card %>
<% if card.considering? && card.auto_close_remind? %>
<%= render "cards/display/preview/badge", label: "Closes in", days: card.auto_close_days_until %>
<% if card.closing_soon? %>
<%= render "cards/display/preview/badge", label: "Closes in", days: card.days_until_close %>
<% end %>
<% end %>
<% end %>