From 935129f0a5cdf8bb29efa57bdaad243c00e5d7d6 Mon Sep 17 00:00:00 2001 From: Donald Zou Date: Mon, 29 Jul 2024 22:17:51 -0400 Subject: [PATCH] Finished the log system, now move on to something else... --- src/dashboard.py | 19 +++++++++++-------- src/static/app/.gitignore | 1 - 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/dashboard.py b/src/dashboard.py index c324881..31a30fc 100644 --- a/src/dashboard.py +++ b/src/dashboard.py @@ -142,10 +142,6 @@ class Logger: except Exception as e: return logs return logs - - - - class PeerJob: def __init__(self, JobID: str, Configuration: str, Peer: str, @@ -176,7 +172,6 @@ class PeerJob: def __dict__(self): return self.toJson() - class PeerJobs: def __init__(self): @@ -232,12 +227,19 @@ class PeerJobs: self.jobdbCursor.execute(''' INSERT INTO PeerJobs VALUES (?, ?, ?, ?, ?, ?, strftime('%Y-%m-%d %H:%M:%S','now'), NULL, ?) ''', (Job.JobID, Job.Configuration, Job.Peer, Job.Field, Job.Operator, Job.Value, Job.Action,)) + JobLogger.log(Job.JobID, Message=f"Job is created if {Job.Field} {Job.Operator} {Job.Value} then {Job.Action}") + else: - self.jobdbCursor.execute(''' - UPDATE PeerJobs SET Field = ?, Operator = ?, Value = ?, Action = ? WHERE JobID = ? - ''', (Job.Field, Job.Operator, Job.Value, Job.Action, Job.JobID)) + currentJob = self.jobdbCursor.execute('SELECT * FROM PeerJobs WHERE JobID = ?', (Job.JobID, )).fetchone() + if currentJob is not None: + self.jobdbCursor.execute(''' + UPDATE PeerJobs SET Field = ?, Operator = ?, Value = ?, Action = ? WHERE JobID = ? + ''', (Job.Field, Job.Operator, Job.Value, Job.Action, Job.JobID)) + JobLogger.log(Job.JobID, + Message=f"Job is updated from if {currentJob['Field']} {currentJob['Operator']} {currentJob['value']} then {currentJob['Action']}; to if {Job.Field} {Job.Operator} {Job.Value} then {Job.Action}") self.jobdb.commit() self.__getJobs() + return True, list( filter(lambda x: x.Configuration == Job.Configuration and x.Peer == Job.Peer and x.JobID == Job.JobID, self.Jobs)) @@ -252,6 +254,7 @@ class PeerJobs: UPDATE PeerJobs SET ExpireDate = strftime('%Y-%m-%d %H:%M:%S','now') WHERE JobID = ? ''', (Job.JobID,)) self.jobdb.commit() + JobLogger.log(Job.JobID, Message=f"Job is removed due to being deleted or finshed.") self.__getJobs() return True, list( filter(lambda x: x.Configuration == Job.Configuration and x.Peer == Job.Peer and x.JobID == Job.JobID, diff --git a/src/static/app/.gitignore b/src/static/app/.gitignore index b130196..06100f8 100644 --- a/src/static/app/.gitignore +++ b/src/static/app/.gitignore @@ -27,5 +27,4 @@ coverage *.sw? *.tsbuildinfo -proxy.js .vite/* \ No newline at end of file