async def get_unbuilt_count(db, ref_id: str) -> int:
    """
    Return a count of unbuilt history changes associated with a given `ref_id`.

    :param db: the application database client
    :param ref_id: the id of the ref to count unbuilt changes for
    :return: the number of unbuilt changes

    """
    return await db.history.count_documents({
        "reference.id": ref_id,
        "index.id": "unbuilt"
    })