expand types and comments in helpers
This commit is contained in:
parent
e8d8c265a7
commit
68c585405d
@ -5,8 +5,8 @@ from typing import Tuple
|
|||||||
|
|
||||||
|
|
||||||
# # # db stuff # # #
|
# # # db stuff # # #
|
||||||
def read_users_points(db: Connection, user_id: str) -> int:
|
def read_users_points(db: Connection, user_id: str) -> int | None:
|
||||||
"""Errors out if user doesn't exist."""
|
"""Returns None and logs error in case of error, or if user doesn't exist."""
|
||||||
try:
|
try:
|
||||||
cursor = db.execute(
|
cursor = db.execute(
|
||||||
"SELECT points FROM points WHERE id = ?",
|
"SELECT points FROM points WHERE id = ?",
|
||||||
@ -18,7 +18,8 @@ def read_users_points(db: Connection, user_id: str) -> int:
|
|||||||
current_app.logger.error(f"Of user: {user_id}")
|
current_app.logger.error(f"Of user: {user_id}")
|
||||||
|
|
||||||
|
|
||||||
def read_all_users_with_username(db: Connection, username: str) -> list[Tuple[str, int]]:
|
def read_all_users_with_username(db: Connection, username: str) -> list[Tuple[str, int]] | None:
|
||||||
|
"""Returns None only if Error was logged."""
|
||||||
try:
|
try:
|
||||||
cursor = db.execute(
|
cursor = db.execute(
|
||||||
"SELECT name, points FROM points WHERE name = ?",
|
"SELECT name, points FROM points WHERE name = ?",
|
||||||
@ -57,7 +58,8 @@ def use_points(db: Connection, user_id: str, points: int) -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def user_exists(db: Connection, user_id: str) -> bool:
|
def user_exists(db: Connection, user_id: str) -> bool | None:
|
||||||
|
"""Returns None only if an error was logged."""
|
||||||
try:
|
try:
|
||||||
cursor = db.execute(
|
cursor = db.execute(
|
||||||
"SELECT points FROM points WHERE id = ?",
|
"SELECT points FROM points WHERE id = ?",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user