import time


def check_if_we_need_to_rate_limit(articles_uploaded, start):
    """Dev.to only allows us to upload 10 articles every 30 seconds.
    So we check if 10 articles have been uploaded then calculate
    the time elapsed. If less than 30 seconds sleep until 30 seconds
    have elapsed. If we do sleep/wait we can then reset the start time
    and articles_uploaded number.

    We stop for 35 seconds because various actions of the script before
    we start uploading the very first article may taken a bit longer
    than when we start timing.

    Args:
        articles_uploaded (int): Number of articles we have uploaded.
        start (time.time): The time we started uploading articles at.

    Returns:
        tuple: article we have uploaded and start time.

    """

    rate_limit_time = 35
    if articles_uploaded == 10:
        end = time.time()
        time_elapsed = end - start

        if time_elapsed < rate_limit_time:
            time.sleep(rate_limit_time - time_elapsed)

        start = time.time()
        articles_uploaded = 0

    return articles_uploaded, start