Fix #5
This commit is contained in:
pare
17e74f8517
commit
e6ae2104a4
S'han modificat 1 arxius amb 5 adicions i 5 eliminacions
10
inactives.py
10
inactives.py
|
@ -9,7 +9,6 @@ import smtplib
|
||||||
from smtplib import SMTPException, SMTPAuthenticationError, SMTPConnectError, SMTPRecipientsRefused
|
from smtplib import SMTPException, SMTPAuthenticationError, SMTPConnectError, SMTPRecipientsRefused
|
||||||
import socket
|
import socket
|
||||||
from socket import gaierror
|
from socket import gaierror
|
||||||
import pdb
|
|
||||||
|
|
||||||
def smtp_config():
|
def smtp_config():
|
||||||
|
|
||||||
|
@ -77,7 +76,7 @@ class Inactives:
|
||||||
def id(self):
|
def id(self):
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# get id of inactive users is
|
# get id of inactive users from inactive database
|
||||||
|
|
||||||
conn = None
|
conn = None
|
||||||
|
|
||||||
|
@ -119,7 +118,7 @@ class Inactives:
|
||||||
|
|
||||||
def delete(self,ids_lst):
|
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
|
i = 0
|
||||||
|
|
||||||
|
@ -183,7 +182,7 @@ class Inactives:
|
||||||
|
|
||||||
cur = conn.cursor()
|
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()
|
rows = cur.fetchall()
|
||||||
|
|
||||||
|
@ -203,7 +202,7 @@ class Inactives:
|
||||||
|
|
||||||
cur.close()
|
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)
|
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,))
|
cur.execute("SELECT datetime FROM " + self.mailing_db_table + " where account_id=(%s)", (id,))
|
||||||
|
|
||||||
row = cur.fetchone()
|
row = cur.fetchone()
|
||||||
|
|
||||||
delta = now-row[0]
|
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))
|
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))
|
||||||
|
|
Loading…
Referencia en una nova incidència