fix: Account count function
All checks were successful
Build Docker / Build Main Image (push) Successful in 20s

This commit is contained in:
Nathan Woodburn 2023-11-17 11:10:04 +11:00
parent 2bf56fed8d
commit 19e2064a7a
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

11
db.py
View File

@ -52,7 +52,6 @@ def get_link_count():
cursor = connection.cursor() cursor = connection.cursor()
cursor.execute("SELECT COUNT(*) FROM links") cursor.execute("SELECT COUNT(*) FROM links")
result = cursor.fetchone() result = cursor.fetchone()
cursor.fetchall()
cursor.close() cursor.close()
connection.close() connection.close()
@ -70,14 +69,18 @@ def get_account_count():
connection = mysql.connector.connect(**dbargs) connection = mysql.connector.connect(**dbargs)
cursor = connection.cursor() cursor = connection.cursor()
cursor.execute("SELECT * FROM links") cursor.execute("SELECT * FROM links")
result = cursor.fetchone() result = cursor.fetchall()
cursor.fetchall()
cursor.close() cursor.close()
connection.close() connection.close()
last_check_account = time.time() last_check_account = time.time()
if result == None: if result == None:
return 0 return 0
return 1
accounts = []
for link in result:
if link[1] not in accounts:
accounts.append(link[1])
return len(accounts)
def delete_token(token): def delete_token(token):
connection = mysql.connector.connect(**dbargs) connection = mysql.connector.connect(**dbargs)