mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Use arel order in account associations
This commit is contained in:
parent
f15e96c1b8
commit
8218a2a671
2 changed files with 3 additions and 1 deletions
|
@ -26,7 +26,7 @@ module Account::Associations
|
||||||
|
|
||||||
# Pinned statuses
|
# Pinned statuses
|
||||||
has_many :status_pins, inverse_of: :account, dependent: :destroy
|
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
|
# Endorsements
|
||||||
has_many :account_pins, inverse_of: :account, dependent: :destroy
|
has_many :account_pins, inverse_of: :account, dependent: :destroy
|
||||||
|
|
|
@ -17,6 +17,8 @@ class StatusPin < ApplicationRecord
|
||||||
|
|
||||||
validates_with StatusPinValidator
|
validates_with StatusPinValidator
|
||||||
|
|
||||||
|
scope :latest, -> { reorder(created_at: :desc) }
|
||||||
|
|
||||||
after_destroy :invalidate_cleanup_info
|
after_destroy :invalidate_cleanup_info
|
||||||
|
|
||||||
def invalidate_cleanup_info
|
def invalidate_cleanup_info
|
||||||
|
|
Loading…
Reference in a new issue