async def get_entity_count_by_sync_id(
    sync_id: UUID,
    db: AsyncSession = Depends(deps.get_db),
    current_user: User = Depends(deps.get_user),
) -> Optional[schemas.EntityCount]:
    """Get the count of entities for a specific sync.

    Args:
        sync_id: The sync ID to count entities for
        db: Database session
        current_user: Current authenticated user

    Returns:
        Count of entities for the specified sync ID
    """
    # will throw 403 if the user doesn't have access to the sync
    sync = await crud.sync.get(db, id=sync_id, current_user=current_user)
    # or return None if the sync doesn't exist
    if not sync:
        raise HTTPException(status_code=404, detail="Sync not found")

    count = await crud.entity.get_count_by_sync_id(db, sync_id=sync_id)
    return schemas.EntityCount(count=count)
Get the count of entities for a specific sync.

    Args:
        sync_id: The sync ID to count entities for
        db: Database session
        current_user: Current authenticated user

    Returns:
        Count of entities for the specified sync ID
    
backend/airweave/api/v1/endpoints/entities.py