From 7605d6c85540c1748d0836d29a63f53844b94237 Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Wed, 20 Dec 2023 13:21:33 +0530 Subject: [PATCH] chore: Sort notifications based on last_activity_at. --- app/finders/notification_finder.rb | 2 +- app/models/notification.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/finders/notification_finder.rb b/app/finders/notification_finder.rb index a80078500..e4f0ff59e 100644 --- a/app/finders/notification_finder.rb +++ b/app/finders/notification_finder.rb @@ -60,6 +60,6 @@ class NotificationFinder end def notifications - @notifications.page(current_page).per(RESULTS_PER_PAGE).order(updated_at: :desc) + @notifications.page(current_page).per(RESULTS_PER_PAGE).order(last_activity_at: :asc) end end diff --git a/app/models/notification.rb b/app/models/notification.rb index fdc8e287c..3cdf8d0be 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -49,7 +49,7 @@ class Notification < ApplicationRecord # TODO: Get rid of default scope # https://stackoverflow.com/a/1834250/939299 - default_scope { order(id: :desc) } + default_scope { order(last_activity_at: :desc) } PRIMARY_ACTORS = ['Conversation'].freeze