1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00

Fix limit handling in grouped notifications CTE (#30685)

This commit is contained in:
Claire 2024-06-13 14:42:40 +02:00 committed by GitHub
parent fe74045576
commit 37f53542fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -152,6 +152,7 @@ class Notification < ApplicationRecord
.limit(1),
query
.joins('CROSS JOIN grouped_notifications')
.where('array_length(grouped_notifications.groups, 1) < :limit', limit: limit)
.where('notifications.id < grouped_notifications.id')
.where.not("COALESCE(notifications.group_key, 'ungrouped-' || notifications.id) = ANY(grouped_notifications.groups)")
.select('notifications.*', "array_append(grouped_notifications.groups, COALESCE(notifications.group_key, 'ungrouped-' || notifications.id))")
@ -179,6 +180,7 @@ class Notification < ApplicationRecord
.limit(1),
query
.joins('CROSS JOIN grouped_notifications')
.where('array_length(grouped_notifications.groups, 1) < :limit', limit: limit)
.where('notifications.id > grouped_notifications.id')
.where.not("COALESCE(notifications.group_key, 'ungrouped-' || notifications.id) = ANY(grouped_notifications.groups)")
.select('notifications.*', "array_append(grouped_notifications.groups, COALESCE(notifications.group_key, 'ungrouped-' || notifications.id))")