mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2024-11-06 16:00:28 +01:00
Finished the log system, now move on to something else...
This commit is contained in:
parent
63e8553a09
commit
935129f0a5
@ -143,10 +143,6 @@ class Logger:
|
||||
return logs
|
||||
return logs
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class PeerJob:
|
||||
def __init__(self, JobID: str, Configuration: str, Peer: str,
|
||||
Field: str, Operator: str, Value: str, CreationDate: datetime, ExpireDate: datetime, Action: 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,
|
||||
|
1
src/static/app/.gitignore
vendored
1
src/static/app/.gitignore
vendored
@ -27,5 +27,4 @@ coverage
|
||||
*.sw?
|
||||
|
||||
*.tsbuildinfo
|
||||
proxy.js
|
||||
.vite/*
|
Loading…
Reference in New Issue
Block a user