async def get_next_version(db, ref_id: str) -> int:
    """
    Get the version number that should be used for the next index build.

    :param db: the application database client
    :param ref_id: the id of the reference to get the next version for
    :return: the next version number

    """
    return await db.indexes.count_documents({"reference.id": ref_id, "ready": True})