mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	user_message: Use INSERT ... ON CONFLICT for historical UM creation.
Rather than use a bulk insert via Django, use the faster `bulk_insert_all_ums` that we already have. This also adds a `ON CONFLICT` clause, to make the insert resilient to race conditions. There are currently two callsites, with different desired `ON CONFLICT` behaviours: - For `notify_reaction_update`, if the `UserMessage` had already been created, we would have done nothing to change it. - For `do_update_message_flags`, we would have ensured a specific bit was (un)set. Extend `create_historical_user_messages` and `bulk_insert_all_ums` to support `ON CONFLICT (...) UPDATE SET flags = ...`.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							52e3c8e1b2
						
					
				
				
					commit
					7988aad159
				
			@@ -338,8 +338,9 @@ def do_update_message_flags(
 | 
			
		||||
 | 
			
		||||
            create_historical_user_messages(
 | 
			
		||||
                user_id=user_profile.id,
 | 
			
		||||
                message_ids=historical_message_ids,
 | 
			
		||||
                flags=(DEFAULT_HISTORICAL_FLAGS & ~flagattr) | flag_target,
 | 
			
		||||
                message_ids=list(historical_message_ids),
 | 
			
		||||
                flagattr=flagattr,
 | 
			
		||||
                flag_target=flag_target,
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        to_update = UserMessage.objects.filter(
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user