Use arel order in account associations

This commit is contained in:
Matt Jankowski 2024-07-30 16:56:09 -04:00
parent c3435191a1
commit fd74536f13
2 changed files with 3 additions and 1 deletions

View file

@ -26,7 +26,7 @@ module Account::Associations
# Pinned statuses
has_many :status_pins, inverse_of: :account, dependent: :destroy
has_many :pinned_statuses, -> { reorder('status_pins.created_at DESC') }, through: :status_pins, class_name: 'Status', source: :status
has_many :pinned_statuses, -> { StatusPin.latest }, through: :status_pins, class_name: 'Status', source: :status
# Endorsements
has_many :account_pins, inverse_of: :account, dependent: :destroy

View file

@ -17,6 +17,8 @@ class StatusPin < ApplicationRecord
validates_with StatusPinValidator
scope :latest, -> { reorder(created_at: :desc) }
after_destroy :invalidate_cleanup_info
def invalidate_cleanup_info