def handle_cascade_delete(project_id: int) -> None:
    """
    Due to the combination of soft deletes and audit log functionality,
    cascade deletes for a project can take a long time for large projects.
    This task delegates the cascade delete to tasks for the main related
    entities for a project.
    """

    from environments.tasks import delete_environment
    from features.tasks import delete_feature
    from projects.models import Project
    from segments.tasks import delete_segment

    project = Project.objects.all_with_deleted().get(id=project_id)

    for environment_id in project.environments.values_list("id", flat=True):
        delete_environment.delay(kwargs={"environment_id": environment_id})

    for segment_id in project.segments.values_list("id", flat=True):
        delete_segment.delay(kwargs={"segment_id": segment_id})

    for feature_id in project.features.values_list("id", flat=True):
        delete_feature.delay(kwargs={"feature_id": feature_id})

    Due to the combination of soft deletes and audit log functionality,
    cascade deletes for a project can take a long time for large projects.
    This task delegates the cascade delete to tasks for the main related
    entities for a project.
    
api/projects/tasks.py