mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	We also change the test helper. The tests hopefully read more clearly in places here, and we also communicate to the dev that order is arbitrary.
		
			
				
	
	
		
			20 lines
		
	
	
		
			892 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			892 B
		
	
	
	
		
			Python
		
	
	
	
	
	
from zerver.models import DefaultStream, Stream
 | 
						|
 | 
						|
 | 
						|
def get_slim_realm_default_streams(realm_id: int) -> set[Stream]:
 | 
						|
    # We really want this query to be simple and just get "thin" Stream objects
 | 
						|
    # in one round trip.
 | 
						|
    #
 | 
						|
    # The above is enforced by at least three tests that verify query counts,
 | 
						|
    # and test_query_count in test_subs.py makes sure that the query itself is
 | 
						|
    # not like 11000 bytes, which is what we had in a prior version that used
 | 
						|
    # select_related() with no arguments (and thus joined to too many tables).
 | 
						|
    #
 | 
						|
    # Please be careful about modifying this code, as it has had a history
 | 
						|
    # of performance problems.
 | 
						|
    return set(Stream.objects.filter(defaultstream__realm_id=realm_id))
 | 
						|
 | 
						|
 | 
						|
def get_default_stream_ids_for_realm(realm_id: int) -> set[int]:
 | 
						|
    return set(DefaultStream.objects.filter(realm_id=realm_id).values_list("stream_id", flat=True))
 |