about summary refs log tree commit diff
path: root/app/models/announcement.rb
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2020-11-04 21:15:22 +0100
committerGitHub <noreply@github.com>2020-11-04 21:15:22 +0100
commitb29defb851f091d9b4419ea149b44dac7944bd06 (patch)
tree82608a918aa8a90af9fa4ebb0876c4e190f98e34 /app/models/announcement.rb
parentd6fe0c94ca48a10d579cf5ec321c33c6124b402d (diff)
Change order of announcements in admin page to sort them newest-first (#15091)
* Change order of announcements in admin page to sort show newly-created first

Fixes #15090

* Use reverse-chronological rather than creation date only
Diffstat (limited to 'app/models/announcement.rb')
-rw-r--r--app/models/announcement.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/app/models/announcement.rb b/app/models/announcement.rb
index c493604c2..f8183aabc 100644
--- a/app/models/announcement.rb
+++ b/app/models/announcement.rb
@@ -22,6 +22,7 @@ class Announcement < ApplicationRecord
   scope :published, -> { where(published: true) }
   scope :without_muted, ->(account) { joins("LEFT OUTER JOIN announcement_mutes ON announcement_mutes.announcement_id = announcements.id AND announcement_mutes.account_id = #{account.id}").where('announcement_mutes.id IS NULL') }
   scope :chronological, -> { order(Arel.sql('COALESCE(announcements.starts_at, announcements.scheduled_at, announcements.published_at, announcements.created_at) ASC')) }
+  scope :reverse_chronological, -> { order(Arel.sql('COALESCE(announcements.starts_at, announcements.scheduled_at, announcements.published_at, announcements.created_at) DESC')) }
 
   has_many :announcement_mutes, dependent: :destroy
   has_many :announcement_reactions, dependent: :destroy