fix: fixed game_id path to show all times from the game

This commit is contained in:
iritmaximus
2023-03-04 13:45:35 +02:00
parent 1a04254684
commit e41796237a
3 changed files with 16 additions and 7 deletions
+5 -5
View File
@@ -11,18 +11,18 @@ table, tr, td {
<h2>Times</h2>
<table>
<tr>
<td>Time</td>
<td>Course</td>
<td>Cup</td>
<td>Time</td>
<td>User</td>
</tr>
{% if times_exist %}
{% for time in times %}
<tr>
<td>time[0]</td>
<td>time[1]</td>
<td>time[2]</td>
<td>time[3]</td>
<td>{{time[0]}}</td>
<td>{{time[1]}}</td>
<td>{{time[2]}}</td>
<td>{{time[3]}}</td>
</tr>
{% endfor %}
{% endif %}
+8 -1
View File
@@ -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
+3 -1
View File
@@ -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/<string:game_name>")