Fix limit handling in grouped notifications CTE (#30685)

pull/30687/head
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
1 changed files with 2 additions and 0 deletions

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))")