1
0
Fork 0
forked from bton/matekasse

removed print and fixed removeaddtag

This commit is contained in:
2000-Trek 2023-06-09 23:24:44 +02:00
parent ef9e53576f
commit 998e03534e

19
main.py
View file

@ -182,28 +182,27 @@ def get_id():
global finished global finished
tag_id = int(request.args.get("id")) tag_id = int(request.args.get("id"))
c.execute(f"SELECT * FROM tags WHERE tagid ={tag_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() queue_item = users.get()
user = queue_item[0] user = queue_item[0]
state = queue_item[1] state = queue_item[1]
if state == "add": if state == "add":
c.execute(f"INSERT OR IGNORE INTO tags (tagid, userid) VALUES ({tag_id}, {user})") c.execute(f"INSERT OR IGNORE INTO tags (tagid, userid) VALUES ({tag_id}, {user})")
elif state == "remove": elif state == "remove":
print(f"remove {tag_id} from {users}")
c.execute(f"DELETE FROM tags WHERE (tagid = {tag_id} AND userid = {user}) ") c.execute(f"DELETE FROM tags WHERE (tagid = {tag_id} AND userid = {user}) ")
conn.commit() conn.commit()
finished = queue_item finished = queue_item
return make_response("True") 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") return make_response("False")
def main(): def main():