feat: Sort Notification API changes (#8865)

* feat: Inbox sort API changes

* Update notification_finder.rb

* Update notification_finder.rb

* Update notification_finder.rb
This commit is contained in:
Muhsin Keloth
2024-02-06 21:03:22 +05:30
committed by GitHub
parent a4fc28abc0
commit d67b91d2b0
2 changed files with 43 additions and 1 deletions

View File

@@ -26,6 +26,7 @@ class NotificationFinder
def set_up
find_all_notifications
filter_by_read_status
filter_by_status
end
@@ -37,11 +38,15 @@ class NotificationFinder
@notifications = @notifications.where('snoozed_until > ?', DateTime.now.utc) if params[:status] == 'snoozed'
end
def filter_by_read_status
@notifications = @notifications.where.not(read_at: nil) if params[:type] == 'read'
end
def current_page
params[:page] || 1
end
def notifications
@notifications.page(current_page).per(RESULTS_PER_PAGE).order(last_activity_at: :desc)
@notifications.page(current_page).per(RESULTS_PER_PAGE).order(last_activity_at: params[:sort_order] || :desc)
end
end