add more info to sync history
This commit is contained in:
parent
c3e6e68bb6
commit
5870303c74
|
@ -30,7 +30,7 @@ class EmailDatabase:
|
|||
self.conn = sqlite3.connect(filepath)
|
||||
cursor = self.conn.cursor()
|
||||
cursor.execute(f'CREATE TABLE IF NOT EXISTS folders_mapping (name TEXT UNIQUE, table_name TEXT UNIQUE)')
|
||||
cursor.execute(f'CREATE TABLE IF NOT EXISTS syncs (timestamp INTEGER UNIQUE, type TEXT)')
|
||||
cursor.execute(f'CREATE TABLE IF NOT EXISTS syncs (timestamp INTEGER UNIQUE, type TEXT, new_emails INTEGER, new_attachments INTEGER, new_folders INTEGER, duration INTEGER)')
|
||||
self.conn.commit()
|
||||
cursor.close()
|
||||
|
||||
|
@ -64,10 +64,10 @@ class EmailDatabase:
|
|||
cursor.close()
|
||||
return new_email
|
||||
|
||||
def finish_sync(self, sync_type: str):
|
||||
def finish_sync(self, sync_type: str, new_emails: int, new_attachments: int, duration: int):
|
||||
now = int(time.time())
|
||||
cursor = self.conn.cursor()
|
||||
cursor.execute('INSERT INTO syncs (timestamp, type) VALUES (?, ?)', (now, sync_type))
|
||||
cursor.execute('INSERT INTO syncs (timestamp, type, new_emails, new_attachments, duration) VALUES (?, ?, ?, ?, ?)', (now, sync_type, new_emails, new_attachments, duration))
|
||||
self.conn.commit()
|
||||
cursor.close()
|
||||
return now
|
||||
|
|
6
run.py
6
run.py
|
@ -68,10 +68,10 @@ def main(args):
|
|||
if len(attachments):
|
||||
new_attachments += 1
|
||||
|
||||
database.finish_sync('refresh' if not did_full_sync else 'full')
|
||||
|
||||
elapsed = datetime.now() - sync_start_time
|
||||
logger.info(f'Finished email {"refresh" if not did_full_sync else "sync"} in {humanize.naturaldelta(elapsed)} and added {new_emails} new emails.')
|
||||
database.finish_sync('refresh' if not did_full_sync else 'full', new_emails, new_attachments, int(elapsed.total_seconds()))
|
||||
|
||||
logger.info(f'Finished email {"refresh" if not did_full_sync else "sync"} in {humanize.naturaldelta(elapsed)} and added {new_emails} new emails and {new_attachments} attachments.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in New Issue