mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	soft-deactivation: Refactor fetching list of existing UserMessages.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							8c5425e33a
						
					
				
				
					commit
					4d77ffe2cb
				
			@@ -137,12 +137,10 @@ def add_missing_messages(user_profile: UserProfile) -> None:
 | 
				
			|||||||
        recipient__id__in=recipient_ids,
 | 
					        recipient__id__in=recipient_ids,
 | 
				
			||||||
        id__gt=user_profile.last_active_message_id).order_by('id').values(
 | 
					        id__gt=user_profile.last_active_message_id).order_by('id').values(
 | 
				
			||||||
        'id', 'recipient__type_id'))
 | 
					        'id', 'recipient__type_id'))
 | 
				
			||||||
    already_created_um_objs = list(UserMessage.objects.filter(
 | 
					    already_created_ums = set(UserMessage.objects.filter(
 | 
				
			||||||
        user_profile=user_profile,
 | 
					        user_profile=user_profile,
 | 
				
			||||||
        message__recipient__type=Recipient.STREAM,
 | 
					        message__recipient__type=Recipient.STREAM,
 | 
				
			||||||
        message__id__gt=user_profile.last_active_message_id).values(
 | 
					        message__id__gt=user_profile.last_active_message_id).values_list('message__id', flat=True))
 | 
				
			||||||
        'message__id'))
 | 
					 | 
				
			||||||
    already_created_ums = set([obj['message__id'] for obj in already_created_um_objs])
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Filter those messages for which UserMessage rows have been already created
 | 
					    # Filter those messages for which UserMessage rows have been already created
 | 
				
			||||||
    all_stream_msgs = [msg for msg in all_stream_msgs
 | 
					    all_stream_msgs = [msg for msg in all_stream_msgs
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user