Fix error decrementing status count when FeaturedTags#last_status_at is nil (#33320)

This commit is contained in:
Claire 2024-12-16 13:33:55 +01:00 committed by GitHub
parent cf4595967b
commit 6305b6e747
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -47,7 +47,7 @@ class FeaturedTag < ApplicationRecord
def decrement(deleted_status)
if statuses_count <= 1
update(statuses_count: 0, last_status_at: nil)
elsif last_status_at > deleted_status.created_at
elsif last_status_at.present? && last_status_at > deleted_status.created_at
update(statuses_count: statuses_count - 1)
else
# Fetching the latest status creation time can be expensive, so only perform it