dashboard wrong points workaround
dashboard now shows the points of every user with same username
This commit is contained in:
parent
f0077c56dc
commit
2cf2050dac
|
@ -46,18 +46,14 @@ def read_users_points(db, user_id):
|
|||
print("To user:", user_id)
|
||||
|
||||
|
||||
def read_users_points_from_username(db, username):
|
||||
"""Returns None if user doesn't exist, their points otherwise."""
|
||||
def read_all_users_with_username(db, username):
|
||||
try:
|
||||
cursor = db.execute(
|
||||
"SELECT points FROM points WHERE name = ?",
|
||||
"SELECT name, points FROM points WHERE name = ?",
|
||||
(username,)
|
||||
)
|
||||
points = cursor.fetchone()
|
||||
if points is None:
|
||||
return None
|
||||
else:
|
||||
return points[0]
|
||||
users = cursor.fetchall()
|
||||
return users
|
||||
except Error as e:
|
||||
print("Error occured reading points from username:", e.args[0])
|
||||
print("To user:", username)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from flask import render_template, Blueprint, request
|
||||
from tlapbot.db import get_db
|
||||
from tlapbot.owncast_helpers import (pretty_redeem_queue, all_counters,
|
||||
read_users_points_from_username)
|
||||
read_all_users_with_username)
|
||||
from datetime import datetime, timezone
|
||||
|
||||
bp = Blueprint('redeem_dashboard', __name__)
|
||||
|
@ -14,13 +14,13 @@ def dashboard():
|
|||
counters = all_counters(db)
|
||||
username = request.args.get("username")
|
||||
if username is not None:
|
||||
user_points = read_users_points_from_username(db, username)
|
||||
users = read_all_users_with_username(db, username)
|
||||
else:
|
||||
user_points = None
|
||||
users = []
|
||||
utc_timezone = timezone.utc
|
||||
return render_template('dashboard.html',
|
||||
queue=queue,
|
||||
counters=counters,
|
||||
username=username,
|
||||
user_points=user_points,
|
||||
users=users,
|
||||
utc_timezone=utc_timezone)
|
||||
|
|
|
@ -5,17 +5,19 @@
|
|||
<title>Redeems Dashboard</title>
|
||||
</head>
|
||||
<body>
|
||||
{% if (username and user_points ) %}
|
||||
{% if (username and users ) %}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Your points balance:</th>
|
||||
<th>Points balance:</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% for user in users %}
|
||||
<tbody>
|
||||
<td> {{ username }} </td>
|
||||
<td> {{ user_points }} </td>
|
||||
<td> {{ user[0] }} </td>
|
||||
<td> {{ user[1] }} </td>
|
||||
</tbody>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endif %}
|
||||
|
||||
|
|
Loading…
Reference in New Issue