fixed logs
This commit is contained in:
parent
5cbf06aaaf
commit
d5a66cee05
@ -128,24 +128,24 @@ class DatabaseHelper:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def getLatestLogs(self):
|
def getLatestLogs(self, public_key):
|
||||||
if not self.conn:
|
if not self.conn:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.cursor.execute("SELECT * FROM `logs` ORDER BY `id` DESC LIMIT 10")
|
self.cursor.execute("SELECT * FROM `logs` WHERE `public_key` = ? ORDER BY `id` DESC LIMIT 10", (public_key,))
|
||||||
|
|
||||||
return self.cursor.fetchall()
|
return self.cursor.fetchall()
|
||||||
|
|
||||||
except sqlite3.Error as error:
|
except sqlite3.Error as error:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def getUreandLogs(self):
|
def getUreandLogs(self, public_key):
|
||||||
if not self.conn:
|
if not self.conn:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.cursor.execute("SELECT * FROM `logs` WHERE `unread` = ?", (0,))
|
self.cursor.execute("SELECT * FROM `logs` WHERE (`unread` = ? AND `public_key` = ?)", (0, public_key))
|
||||||
|
|
||||||
return self.cursor.fetchall()
|
return self.cursor.fetchall()
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ from helpers import UtilityHelper as utilityHelper
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
def displayUnreadLogs(self):
|
def displayUnreadLogs(self):
|
||||||
logs = self.db.getUreandLogs
|
logs = self.db.getUreandLogs(self.user.public_ser)
|
||||||
|
|
||||||
if len(logs) == 0:
|
if len(logs) == 0:
|
||||||
return False
|
return False
|
||||||
@ -10,10 +10,10 @@ def displayUnreadLogs(self):
|
|||||||
printLogs(logs)
|
printLogs(logs)
|
||||||
|
|
||||||
for log in logs:
|
for log in logs:
|
||||||
self.db.updateLog(log[0])
|
self.db.updateLogStatus(log[0])
|
||||||
|
|
||||||
def displayLogs(self):
|
def displayLogs(self):
|
||||||
logs = self.db.getLatestLogs()
|
logs = self.db.getLatestLogs(self.user.public_ser)
|
||||||
if len(logs) == 0:
|
if len(logs) == 0:
|
||||||
print(f"{utilityHelper.warningMessage('No logs found')}")
|
print(f"{utilityHelper.warningMessage('No logs found')}")
|
||||||
return False
|
return False
|
||||||
@ -24,7 +24,7 @@ def printLogs(logs):
|
|||||||
for log in logs:
|
for log in logs:
|
||||||
print(f"------------------{log[0]}---------------------")
|
print(f"------------------{log[0]}---------------------")
|
||||||
print(f"Log Date:")
|
print(f"Log Date:")
|
||||||
print(f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(log[2]))}")
|
print(f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(float(log[2])))}")
|
||||||
print(f"Log Message:")
|
print(f"Log Message:")
|
||||||
print(f"{log[3]}")
|
print(f"{log[3]}")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user