Fix limit handling in grouped notifications CTE (#30685)
This commit is contained in:
		
							parent
							
								
									fe74045576
								
							
						
					
					
						commit
						37f53542fe
					
				@ -152,6 +152,7 @@ class Notification < ApplicationRecord
 | 
				
			|||||||
              .limit(1),
 | 
					              .limit(1),
 | 
				
			||||||
            query
 | 
					            query
 | 
				
			||||||
              .joins('CROSS JOIN grouped_notifications')
 | 
					              .joins('CROSS JOIN grouped_notifications')
 | 
				
			||||||
 | 
					              .where('array_length(grouped_notifications.groups, 1) < :limit', limit: limit)
 | 
				
			||||||
              .where('notifications.id < grouped_notifications.id')
 | 
					              .where('notifications.id < grouped_notifications.id')
 | 
				
			||||||
              .where.not("COALESCE(notifications.group_key, 'ungrouped-' || notifications.id) = ANY(grouped_notifications.groups)")
 | 
					              .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))")
 | 
					              .select('notifications.*', "array_append(grouped_notifications.groups, COALESCE(notifications.group_key, 'ungrouped-' || notifications.id))")
 | 
				
			||||||
@ -179,6 +180,7 @@ class Notification < ApplicationRecord
 | 
				
			|||||||
              .limit(1),
 | 
					              .limit(1),
 | 
				
			||||||
            query
 | 
					            query
 | 
				
			||||||
              .joins('CROSS JOIN grouped_notifications')
 | 
					              .joins('CROSS JOIN grouped_notifications')
 | 
				
			||||||
 | 
					              .where('array_length(grouped_notifications.groups, 1) < :limit', limit: limit)
 | 
				
			||||||
              .where('notifications.id > grouped_notifications.id')
 | 
					              .where('notifications.id > grouped_notifications.id')
 | 
				
			||||||
              .where.not("COALESCE(notifications.group_key, 'ungrouped-' || notifications.id) = ANY(grouped_notifications.groups)")
 | 
					              .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))")
 | 
					              .select('notifications.*', "array_append(grouped_notifications.groups, COALESCE(notifications.group_key, 'ungrouped-' || notifications.id))")
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user