mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	refactor: Extract get_stream_subscriptions_for_user().
This commit is contained in:
		@@ -4,6 +4,7 @@ from django.db.models.query import QuerySet
 | 
			
		||||
from zerver.models import (
 | 
			
		||||
    Recipient,
 | 
			
		||||
    Subscription,
 | 
			
		||||
    UserProfile,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
def get_active_subscriptions_for_stream_id(stream_id):
 | 
			
		||||
@@ -22,6 +23,13 @@ def get_active_subscriptions_for_stream_ids(stream_ids):
 | 
			
		||||
        active=True
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
def get_stream_subscriptions_for_user(user_profile):
 | 
			
		||||
    # type: (UserProfile) -> QuerySet
 | 
			
		||||
    return Subscription.objects.filter(
 | 
			
		||||
        user_profile=user_profile,
 | 
			
		||||
        recipient__type=Recipient.STREAM,
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
def num_subscribers_for_stream_id(stream_id):
 | 
			
		||||
    # type: (int) -> int
 | 
			
		||||
    return get_active_subscriptions_for_stream_id(stream_id).filter(
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user