示例#1
0
def get_round_amount(is_it_handicap):
    sql = "SELECT COUNT (id) FROM rounds WHERE player=:username AND handicap=:handicap"
    result = db.session.execute(sql, {
        "username": user.get_user_session_id(),
        "handicap": is_it_handicap
    })
    return result.fetchone()
示例#2
0
def get_average_putting_score(is_it_handicap):
    sql = "SELECT ROUND(AVG (putts),1) FROM scores AS s LEFT JOIN rounds as r "\
    "ON r.id = s.round_id WHERE player=:username AND handicap=:handicap"
    result = db.session.execute(sql, {
        "username": user.get_user_session_id(),
        "handicap": is_it_handicap
    })
    return result.fetchone()
示例#3
0
def get_user_round_scores(is_handicap):
    sql = "SELECT name, hole, par, strokes, putts, date_played FROM golf_courses AS g"\
     " LEFT JOIN holes AS h ON h.course_id = g.id"\
     " LEFT JOIN rounds AS r ON r.course = g.id"\
     " LEFT JOIN scores AS s ON s.round_id = r.id AND s.hole_id = h.id"\
     " WHERE r.player=:username AND r.handicap=:is_handicap ORDER BY date_played,hole"
    result = db.session.execute(sql, {"username":user.get_user_session_id(),"is_handicap":is_handicap})
    return result.fetchall()
示例#4
0
def get_round_shot_min(is_it_handicap):
    sql = "SELECT round(min(s),0) FROM (SELECT SUM(strokes) AS s from scores "\
    "LEFT JOIN rounds ON rounds.id = scores.round_id WHERE player=:username "\
    "AND handicap=:handicap GROUP BY scores.round_id)sumtable"

    result = db.session.execute(sql, {
        "username": user.get_user_session_id(),
        "handicap": is_it_handicap
    })
    return result.fetchone()
示例#5
0
def scores():
    if request.method == "GET":
        course_names = courses.get_active_course_names()
        return render_template("/scores.html", active_courses=course_names)
    if request.method == "POST":
        course_name = request.form["course"]
        hole_details = courses.get_course_hole_details(course_name)
        user_id = user.get_user_session_id()
        friends = user.get_friends()
        return render_template("/post_scores.html", course_name=course_name, hole_details = hole_details,user_id=user_id, friends=friends)
示例#6
0
def profile():
    if request.method == "GET":
        friendlist = user.get_friends()
        if(friendlist == None):
            friendlist = [""]
        return render_template("/profile.html", user_data=user.get_user_profile(), friendlist=friendlist)
    if request.method == "POST":
        friend_name = request.form['friend']
        if(friend_name != user.get_user_session_id()):
            user.add_friend(friend_name)
        return redirect("/profile")