async def _compute_collection_status(
        self, db: AsyncSession, collection: Collection, current_user: schemas.User
    ) -> CollectionStatus:
        """Compute the ephemeral status of a collection based on its source connections.

        Logic:
        - If no source connections: NEEDS_SOURCE
        - If all source connections are failing: ERROR
        - If some source connections are failing: PARTIAL_ERROR
        - If any source connection is in progress: ACTIVE (this is considered an OK state)
        - Otherwise: ACTIVE

        Args:
            db: The database session
            collection: The collection
            current_user: Current user for authorization

        Returns:
            The computed ephemeral status
        """
        # Get all source connections for this collection
        source_connections = await crud_source_connection.get_for_collection(
            db, readable_collection_id=collection.readable_id, current_user=current_user
        )

        # If no source connections, the collection needs one
        if not source_connections:
            return CollectionStatus.NEEDS_SOURCE

        # Count the number of failing source connections
        failing_count = 0
        in_progress_count = 0

        for sc in source_connections:
            if sc.status == SourceConnectionStatus.FAILING:
                failing_count += 1
            elif sc.status == SourceConnectionStatus.IN_PROGRESS:
                in_progress_count += 1

        # If any are in progress, the collection is active (in progress is considered an OK state)
        if in_progress_count > 0:
            return CollectionStatus.ACTIVE

        # If all are failing, the collection is in error
        if failing_count == len(source_connections):
            return CollectionStatus.ERROR

        # If some but not all are failing, the collection is in partial error
        if failing_count > 0:
            return CollectionStatus.PARTIAL_ERROR

        # Otherwise, the collection is active
        return CollectionStatus.ACTIVE
Compute the ephemeral status of a collection based on its source connections.

        Logic:
        - If no source connections: NEEDS_SOURCE
        - If all source connections are failing: ERROR
        - If some source connections are failing: PARTIAL_ERROR
        - If any source connection is in progress: ACTIVE (this is considered an OK state)
        - Otherwise: ACTIVE

        Args:
            db: The database session
            collection: The collection
            current_user: Current user for authorization

        Returns:
            The computed ephemeral status
        
backend/airweave/crud/crud_collection.py