Delete no feedback inactive users. Fix #4
This commit is contained in:
pare
d11498f9f7
commit
f7836b1fae
S'han modificat 1 arxius amb 15 adicions i 5 eliminacions
|
@ -9,7 +9,7 @@ import sys
|
||||||
import os.path
|
import os.path
|
||||||
import psycopg2
|
import psycopg2
|
||||||
|
|
||||||
def delete_inactives(mailing_db, mailing_db_user, mailing_db_table, query, id_array, username_array):
|
def delete_inactives(mailing_db, mailing_db_user, mailing_db_table, deletion_accepted, query, id_array, username_array):
|
||||||
|
|
||||||
conn = None
|
conn = None
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ def delete_inactives(mailing_db, mailing_db_user, mailing_db_table, query, id_ar
|
||||||
|
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
|
|
||||||
# executem SELECT
|
|
||||||
cur.execute(query)
|
cur.execute(query)
|
||||||
|
|
||||||
for row in cur:
|
for row in cur:
|
||||||
|
@ -29,10 +28,19 @@ def delete_inactives(mailing_db, mailing_db_user, mailing_db_table, query, id_ar
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
if len(id_array) == 0:
|
if len(id_array) == 0:
|
||||||
sys.exit("None inactive users found!")
|
if deletion_accepted == True:
|
||||||
|
print("None inactive users who accepted to be deleted found!")
|
||||||
|
elif deletion_accepted == False:
|
||||||
|
print("None inactive users to be deleted!")
|
||||||
|
return
|
||||||
|
|
||||||
while i < len(id_array):
|
while i < len(id_array):
|
||||||
|
|
||||||
|
if deletion_accepted == True:
|
||||||
|
print("Deleting inactive users who accepted to be deleted...")
|
||||||
|
elif deletion_accepted == False:
|
||||||
|
print("Deleting inactive users who do not reply our email...")
|
||||||
|
|
||||||
print("\n")
|
print("\n")
|
||||||
print("Deleting user " + str(i) + " of " + str(len(id_array)) + " users")
|
print("Deleting user " + str(i) + " of " + str(len(id_array)) + " users")
|
||||||
print("Deleting user with id " + str(id_array[i]) + ", username: " + username_array[i])
|
print("Deleting user with id " + str(id_array[i]) + ", username: " + username_array[i])
|
||||||
|
@ -127,16 +135,18 @@ rvm_ruby = os.environ['HOME'] + "/.rbenv/shims/ruby"
|
||||||
# select users who replied the warning email saying yes to deletion
|
# select users who replied the warning email saying yes to deletion
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
deletion_accepted = True
|
||||||
query = "select account_id, username, email, to_be_deleted, feedback, recipient_error, elapsed_days from " + mailing_db_table + " where to_be_deleted = 't' and feedback = 't' and recipient_error = 'f' and emailed_at < now() - interval '31 days'"
|
query = "select account_id, username, email, to_be_deleted, feedback, recipient_error, elapsed_days from " + mailing_db_table + " where to_be_deleted = 't' and feedback = 't' and recipient_error = 'f' and emailed_at < now() - interval '31 days'"
|
||||||
id_array = []
|
id_array = []
|
||||||
username_array = []
|
username_array = []
|
||||||
delete_inactives(mailing_db, mailing_db_user, mailing_db_table, query, id_array, username_array)
|
delete_inactives(mailing_db, mailing_db_user, mailing_db_table, deletion_accepted, query, id_array, username_array)
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# select users who don't replied to email after 30 days
|
# select users who don't replied to email after 30 days
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
deletion_accepted = False
|
||||||
query = "select account_id, username, email, to_be_deleted, feedback, recipient_error, elapsed_days from inactive_users where to_be_deleted = 'f' and feedback = 'f' and recipient_error = 'f' and emailed_at < now() - interval '31 days'"
|
query = "select account_id, username, email, to_be_deleted, feedback, recipient_error, elapsed_days from inactive_users where to_be_deleted = 'f' and feedback = 'f' and recipient_error = 'f' and emailed_at < now() - interval '31 days'"
|
||||||
id_array = []
|
id_array = []
|
||||||
username_array = []
|
username_array = []
|
||||||
delete_inactives(mailing_db, mailing_db_user, mailing_db_table, query, id_array, username_array)
|
delete_inactives(mailing_db, mailing_db_user, mailing_db_table, deletion_accepted, query, id_array, username_array)
|
||||||
|
|
Loading…
Referencia en una nova incidència