indent fixes + new helpers + updated helpers

This commit is contained in:
Lili (Tlapka) 2022-10-12 15:30:12 +02:00
parent 062e1c113e
commit 1faee35169
1 changed files with 30 additions and 17 deletions

View File

@ -107,23 +107,36 @@ def change_display_name(db, user_id, new_name):
print("To user:", user_id, new_name)
def add_to_redeem_queue(db, user_id, redeem_name):
def add_to_counter(db, counter_name):
try:
cursor = db.execute(
"INSERT INTO redeem_queue(redeem, redeemer_id) VALUES(?, ?)",
(redeem_name, user_id)
"UPDATE counters SET count = count + 1 WHERE name = ?",
(counter_name,)
)
db.commit()
except Error as e:
print("Error occured adding to counter:", e.args[0])
print("To counter:", counter_name)
def add_to_redeem_queue(db, user_id, redeem_name, note=None):
try:
cursor = db.execute(
"INSERT INTO redeem_queue(redeem, redeemer_id, note) VALUES(?, ?, ?)",
(redeem_name, user_id, note)
)
db.commit()
except Error as e:
print("Error occured adding to redeem queue:", e.args[0])
print("To user:", user_id, " with redeem:", redeem_name)
print("To user:", user_id, " with redeem:", redeem_name, "with note:", note)
def clear_redeem_queue(db):
try:
cursor = db.execute(
"DELETE FROM redeem_queue"
)
cursor.execute(
"""UPDATE counters SET counter_count = 0"""
)
db.commit()
except Error as e:
print("Error occured deleting redeem queue:", e.args[0])
@ -131,7 +144,7 @@ def clear_redeem_queue(db):
def pretty_redeem_queue(db):
try:
cursor = db.execute(
"""SELECT redeem_queue.created, redeem_queue.redeem, points.name
"""SELECT redeem_queue.created, redeem_queue.redeem, redeem_queue.note, points.name
FROM redeem_queue
INNER JOIN points
on redeem_queue.redeemer_id = points.id"""