From e6ae2104a4c0b932536b6128c83cfd3fc4c0cd14 Mon Sep 17 00:00:00 2001 From: spla Date: Mon, 1 Aug 2022 20:25:54 +0200 Subject: [PATCH] Fix #5 --- inactives.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/inactives.py b/inactives.py index 5f856f9..b8b905b 100644 --- a/inactives.py +++ b/inactives.py @@ -9,7 +9,6 @@ import smtplib from smtplib import SMTPException, SMTPAuthenticationError, SMTPConnectError, SMTPRecipientsRefused import socket from socket import gaierror -import pdb def smtp_config(): @@ -77,7 +76,7 @@ class Inactives: def id(self): ############################################################################### - # get id of inactive users is + # get id of inactive users from inactive database conn = None @@ -119,7 +118,7 @@ class Inactives: def delete(self,ids_lst): - print(f'Checking {len(ids_lst)} ids to delete reactivated or deleted accounts...') + print(f'\nChecking {len(ids_lst)} ids to delete reactivated or deleted accounts...') i = 0 @@ -183,7 +182,7 @@ class Inactives: cur = conn.cursor() - cur.execute("select account_id, email from users where current_sign_in_at < now() - interval '180 days' and disabled=False and approved=True order by current_sign_in_at desc;") + cur.execute("select account_id, email, current_sign_in_at from users where current_sign_in_at < now() - interval '180 days' and disabled=False and approved=True order by current_sign_in_at desc") rows = cur.fetchall() @@ -203,7 +202,7 @@ class Inactives: cur.close() - print(f'inactive accounts: {len(inactive_account_id)}') + print(f'inactive accounts found: {len(inactive_account_id)}') return (inactive_account_id, inactive_email, current_sign_in_at) @@ -374,6 +373,7 @@ class Inactives: cur.execute("SELECT datetime FROM " + self.mailing_db_table + " where account_id=(%s)", (id,)) row = cur.fetchone() + delta = now-row[0] cur.execute("UPDATE " + self.mailing_db_table + " SET elapsed_days=(%s), email=(%s), emailed=(%s), current_sign_in_at=(%s) where account_id=(%s)", (delta.days, email, emailed, current_sign_in_at, id))