mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-12-16 16:36:17 +00:00
Stable for SQLite and PostgreSQL
This commit is contained in:
@@ -68,10 +68,10 @@ class PeerJobLogger:
|
|||||||
db.select(
|
db.select(
|
||||||
self.jobLogTable.c.JobID
|
self.jobLogTable.c.JobID
|
||||||
).where(
|
).where(
|
||||||
db.or_(
|
(db.or_(
|
||||||
self.jobLogTable.c.Status == 'false',
|
self.jobLogTable.c.Status == 'false',
|
||||||
self.jobLogTable.c.Status == 0
|
self.jobLogTable.c.Status == 0
|
||||||
)
|
) if conn.dialect.name == 'sqlite' else self.jobLogTable.c.Status == 'false')
|
||||||
).group_by(
|
).group_by(
|
||||||
self.jobLogTable.c.JobID
|
self.jobLogTable.c.JobID
|
||||||
).having(
|
).having(
|
||||||
@@ -97,4 +97,5 @@ class PeerJobLogger:
|
|||||||
def vacuum(self):
|
def vacuum(self):
|
||||||
with self.engine.begin() as conn:
|
with self.engine.begin() as conn:
|
||||||
if conn.dialect.name == 'sqlite':
|
if conn.dialect.name == 'sqlite':
|
||||||
|
print("[WGDashboard] SQLite Vacuuming PeerJogLogs Database")
|
||||||
conn.execute(db.text('VACUUM;'))
|
conn.execute(db.text('VACUUM;'))
|
||||||
@@ -192,24 +192,22 @@ class PeerJobs:
|
|||||||
self.deleteJob(j)
|
self.deleteJob(j)
|
||||||
|
|
||||||
def cleanJob(self, init = False):
|
def cleanJob(self, init = False):
|
||||||
|
|
||||||
failingJobs = self.JobLogger.getFailingJobs()
|
failingJobs = self.JobLogger.getFailingJobs()
|
||||||
# with self.engine.begin() as conn:
|
with self.engine.begin() as conn:
|
||||||
# print(conn.dialect.name)
|
for job in failingJobs:
|
||||||
# for job in failingJobs:
|
conn.execute(
|
||||||
# conn.execute(
|
self.peerJobTable.update().values(
|
||||||
# self.peerJobTable.update().values(
|
{
|
||||||
# {
|
"ExpireDate": datetime.now()
|
||||||
# "ExpireDate": datetime.now()
|
}
|
||||||
# }
|
).where(self.peerJobTable.columns.JobID == job.get('JobID'))
|
||||||
# ).where(self.peerJobTable.columns.JobID == job.get('JobID'))
|
)
|
||||||
# )
|
self.JobLogger.deleteLogs(JobID=job.get('JobID'))
|
||||||
# self.JobLogger.deleteLogs(JobID=job.get('JobID'))
|
self.JobLogger.log(job.get('JobID'), Message=f"Job is removed due to being stale.")
|
||||||
# self.JobLogger.log(job.get('JobID'), Message=f"Job is removed due to being stale.")
|
|
||||||
|
|
||||||
with self.engine.connect() as conn:
|
with self.engine.connect() as conn:
|
||||||
if init and conn.dialect.name == 'sqlite':
|
if init and conn.dialect.name == 'sqlite':
|
||||||
print("[WGDashboard] SQLite Vacuuming...")
|
print("[WGDashboard] SQLite Vacuuming PeerJobs Database")
|
||||||
self.JobLogger.vacuum()
|
self.JobLogger.vacuum()
|
||||||
conn.execute(sqlalchemy.text('VACUUM;'))
|
conn.execute(sqlalchemy.text('VACUUM;'))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user