def get_occupied_streams(realm: Realm) -> QuerySet:
    ' Get streams with subscribers '
    exists_expression = Exists(Subscription.objects.filter(active=True, user_profile__is_active=True, user_profile__realm=realm, recipient_id=OuterRef('recipient_id')))
    occupied_streams = Stream.objects.filter(realm=realm, deactivated=False).annotate(occupied=exists_expression).filter(occupied=True)
    return occupied_streams
Get streams with subscribers
def get_occupied_streams(realm: Realm) -> QuerySet:
    '  '
    exists_expression = Exists(Subscription.objects.filter(active=True, user_profile__is_active=True, user_profile__realm=realm, recipient_id=OuterRef('recipient_id')))
    occupied_streams = Stream.objects.filter(realm=realm, deactivated=False).annotate(occupied=exists_expression).filter(occupied=True)
    return occupied_streams