0
0
Fork 0

Fix pagination parameters in GET /api/v2_alpha/notificatins (#31509)

This commit is contained in:
Claire 2024-08-20 15:54:08 +02:00 committed by GitHub
parent fa2e7b1708
commit 711e1fce0a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 9 deletions

View file

@ -180,8 +180,8 @@ class Notification < ApplicationRecord
# Notifications that have no `group_key` each count as a separate group.
def paginate_groups_by_max_id(limit, max_id: nil, since_id: nil)
query = reorder(id: :desc)
query = query.where(id: ...max_id) if max_id.present?
query = query.where(id: (since_id + 1)...) if since_id.present?
query = query.where(id: ...(max_id.to_i)) if max_id.present?
query = query.where(id: (since_id.to_i + 1)...) if since_id.present?
query.paginate_groups(limit, :desc)
end
@ -190,8 +190,8 @@ class Notification < ApplicationRecord
# Results will be in ascending order by id.
def paginate_groups_by_min_id(limit, max_id: nil, min_id: nil)
query = reorder(id: :asc)
query = query.where(id: (min_id + 1)...) if min_id.present?
query = query.where(id: ...max_id) if max_id.present?
query = query.where(id: (min_id.to_i + 1)...) if min_id.present?
query = query.where(id: ...(max_id.to_i)) if max_id.present?
query.paginate_groups(limit, :asc)
end