Beispiel #1
0
def add_one_view_to(face):
    new_views = face.get('views', 0) + 1
    new_views_total = face.get('views_total', 0) + 1
    new_score = compute_score_for(face)
    update_face(face, {'views': new_views,
                       'views_total': new_views_total,
                       'score': new_score})
    # maybe update winner cache
    update_winner_cache_if_winner(face)
Beispiel #2
0
def add_one_vote_to(face, vote_type=REGULAR):
    key = 'nb_votes' if vote_type == REGULAR else 'favorite_votes'
    new_votes = face.get(key, 0) + 1
    new_votes_total = face.get('%s_total' % key, 0) + 1
    new_score = compute_score_for(face)
    update_face(face, {key: new_votes,
                       '%s_total' % key: new_votes_total,
                       'score': new_score})
    # maybe update winner cache
    update_winner_cache_if_winner(face)