From e41796237ad2b037cfaacc9ccc4c744661dd5feb Mon Sep 17 00:00:00 2001 From: iritmaximus Date: Sat, 4 Mar 2023 13:45:35 +0200 Subject: [PATCH] fix: fixed game_id path to show all times from the game --- flaskr/templates/game_id.html | 10 +++++----- flaskr/utils/games.py | 9 ++++++++- flaskr/views/games.py | 4 +++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/flaskr/templates/game_id.html b/flaskr/templates/game_id.html index 6e909f7..fcbe0f8 100644 --- a/flaskr/templates/game_id.html +++ b/flaskr/templates/game_id.html @@ -11,18 +11,18 @@ table, tr, td {

Times

- + {% if times_exist %} {% for time in times %} - - - - + + + + {% endfor %} {% endif %} diff --git a/flaskr/utils/games.py b/flaskr/utils/games.py index d0ffeff..0514f92 100644 --- a/flaskr/utils/games.py +++ b/flaskr/utils/games.py @@ -26,6 +26,13 @@ def get_game_name(id: int): def get_all_times_in_game(id: int): - sql = "SELECT courses.name, times.course_id, users.username FROM times JOIN courses ON courses.id=times.course_id JOIN users ON users.id=times.user_id WHERE times.course_id=:id" + sql = """ + SELECT courses.name, cups.name, times.timems, users.username + FROM times + JOIN courses ON courses.id=times.course_id + JOIN cups ON cups.id=times.cup_id + JOIN users ON users.id=times.user_id + WHERE times.game_id=:id + """ results = db.session.execute(sql, {"id": id}).fetchall() return results diff --git a/flaskr/views/games.py b/flaskr/views/games.py index 90ef89b..f01a6ec 100644 --- a/flaskr/views/games.py +++ b/flaskr/views/games.py @@ -26,7 +26,9 @@ def get_game_by_id(game_id): "error.html", message="Incorrect id, id not found or incorrect value" ) times = get_all_times_in_game(game_id) - return render_template("game_id.html", game_name=game_name, times=times) + return render_template( + "game_id.html", times_exist=True, game_name=game_name, times=times + ) @app.route("/api/game/")
Time Course CupTime User
time[0]time[1]time[2]time[3]{{time[0]}}{{time[1]}}{{time[2]}}{{time[3]}}