Skip to content

Commit

Permalink
Fix client page list query and apscheduler jobid
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Garbato committed Dec 19, 2021
1 parent 6ae0ae6 commit c9f9759
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
12 changes: 10 additions & 2 deletions app/client_mgt.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def info(self):
query = "select count(status) from events where client='%s' and status='KO';" %self.client
count_ko = query_db(query)[0]
#count_total = count_ok + count_ko
query = "select end_ts from events where client='%s' order by id desc limit 1;" %self.client
query = "select lastseen from clients where name='%s';" %self.client
lastseen = query_db(query)
query = "select joindate from clients where name='%s';" % self.client
joindate = query_db(query)
Expand Down Expand Up @@ -182,7 +182,7 @@ def list_clients_threshold(self):
clientlist = query_db(query)
return clientlist

def list_clients_page(self):
def list_clients_page_old(self):
toregister = self.list_clists_to_register()
#print(f"Client to register {toregister}")
maxrows = 50000
Expand Down Expand Up @@ -233,6 +233,11 @@ def list_clients_page(self):
res = query_db(query)
return res

def list_clients_page(self):
query = ("SELECT name,status,joindate,threshold,ssh_key,lastseen from clients;")
res = query_db(query)
return res

def start_sync(self, start_ts, share, status="SYNCING"):
self.start_ts = start_ts
self.share = share
Expand All @@ -252,3 +257,6 @@ def end_sync(self, start_ts, end_ts, status, sync_status, log):
query = ("update events set status='%s', sync_status='%s', end_ts=%d, duration=%d, log='%s' where client='%s' and start_ts=%d") % (status, sync_status, end_ts, duration, log, self.client, start_ts)
query_db(query)
get_db().commit()
query = ("update clients set lastseen='%s' where name='%s'") % (end_ts, self.client)
query_db(query)
get_db().commit()
1 change: 1 addition & 0 deletions app/db_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
share TEXT NOT NULL,
threshold INTEGER NOT NULL,
sync_status TEXT,
lastseen DATETIME,
joindate DATETIME); """


Expand Down
2 changes: 1 addition & 1 deletion app_client/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def scheduler_sync():
}
})

scheduler.add_job(func=scheduler_sync, trigger="interval", seconds=int(sync_interval), next_run_time=datetime.now(), replace_existing=True)
scheduler.add_job(func=scheduler_sync, id="unison_sync_job", trigger="interval", seconds=int(sync_interval), next_run_time=datetime.now(), replace_existing=True)
scheduler.start()


Expand Down

0 comments on commit c9f9759

Please sign in to comment.