예제 #1
0
파일: logic.py 프로젝트: sphoebs/rockshell
def place_delete(place_id, place_key_str):
    try:
        pkey = Place.make_key(place_id, place_key_str)
        cluster_ratings = ClusterRating.get_list({'place': pkey.urlsafe()})
        for cr in cluster_ratings:
            ClusterRating.delete(cr.key)
        user_ratings = Rating.get_list({'place': pkey.urlsafe()})
        for r in user_ratings:
            Rating.delete(r.key)
        res = Place.delete(pkey)
    except TypeError, e:
        return None, str(e), 400
예제 #2
0
def clean_and_update_ratings(clean=True):
    """
    wipes database, requeries API and creates db rows

    In a full project, instead of dangerously wiping all Rating data,
     I'd leave them there and compare the new data to the old, and
     only add the ones I haven't added already.
    """
    if clean:
        print('deleting all Ratings')
        Rating.delete().execute()

    print('fetching from API Ratings')
    all_ratings = udemy_api.get_all_ratings()
    print('adding rows')
    create_bulk_ratings(all_ratings)
    print('done clean_and_update_ratings')