From 998e03534e6ba3c303b9f13a58d997cdb7a33101 Mon Sep 17 00:00:00 2001 From: 2000-Trek Date: Fri, 9 Jun 2023 23:24:44 +0200 Subject: [PATCH] removed print and fixed removeaddtag --- main.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/main.py b/main.py index 66c0da2..e0c9660 100644 --- a/main.py +++ b/main.py @@ -182,27 +182,26 @@ def get_id(): global finished tag_id = int(request.args.get("id")) c.execute(f"SELECT * FROM tags WHERE tagid ={tag_id}") - tag_list = c.fetchall() - print(tag_list) - if tag_list != []: - tag = tag_list[0] - if users.qsize() == 0: - c.execute(f"UPDATE users SET balance = balance - 1 WHERE id={tag[1]}") - conn.commit() - return make_response("True") - elif users.qsize() > 0: + tag_list = c.fetchall() + if users.qsize() > 0: queue_item = users.get() user = queue_item[0] state = queue_item[1] if state == "add": c.execute(f"INSERT OR IGNORE INTO tags (tagid, userid) VALUES ({tag_id}, {user})") elif state == "remove": - print(f"remove {tag_id} from {users}") c.execute(f"DELETE FROM tags WHERE (tagid = {tag_id} AND userid = {user}) ") conn.commit() finished = queue_item return make_response("True") + + elif tag_list != []: + tag = tag_list[0] + if users.qsize() == 0: + c.execute(f"UPDATE users SET balance = balance - 1 WHERE id={tag[1]}") + conn.commit() + return make_response("True") return make_response("False")