def generate_user_stats(username, user_pool):
    user_info = rc.get_user_from_redis(username, user_pool)
    user_stats = {}
    user_stats['display_name'] = User.user_database[username][1]
    user_stats['current_points'] = lg.UserLogic.scoreFromTuple(user_info)
    user_stats['starting_points'] = user_info[1]
    user_stats['points_for_solving'] = user_info[2]
    user_stats['points_for_selling'] = user_info[3]
    user_stats['expenditure'] = user_info[4]
    user_stats['problems_solved'] = user_info[5]
    user_stats['solutions_bought'] = user_info[6]
    user_stats['solutions_sold'] = user_info[7]
    return user_stats
Esempio n. 2
0
def show_scores():
    users = [(user, User.user_database[user][1]) for user in User.user_database]
    users_info = []
    for user, display_name in users:
        try:
            user_info = rc.get_user_from_redis(user, user_pool)
            users_info.append((user, display_name, lg.UserLogic.scoreFromTuple(user_info), len(user_info[5])))
        except TypeError:
            pass
    users_info.sort(key=lambda x: x[2], reverse=True)
    positions = enumerate(users_info)
    if current_user.is_anonymous:
        return render_template("scores.html", scores=positions)
    else:
        return render_template("scores.html", scores=positions, logged_in_user=current_user)
def get_user_points(username, user_pool):
    user_info = rc.get_user_from_redis(username, user_pool)
    return lg.UserLogic.scoreFromTuple(user_info)