Added new edit_status.py instructions

This commit is contained in:
spla 2020-06-29 10:25:11 +02:00
pare 5ecd4137d8
commit 06f712fffd
S'han modificat 2 arxius amb 13 adicions i 11 eliminacions

Veure arxiu

@ -17,14 +17,16 @@ Run mailing.py periodically to catch 'new' inactive users and update the elapsed
Within Python Virtual Environment:
1. Run 'db-setup.py' to set database parameters and create needed database and table. All collected data of inactive users (see point 3) will be written there.
1. Run `python db-setup.py` to set database parameters and create needed database and table. All collected data of inactive users (see point 3) will be written there.
2. Run 'setup.py' to set your SMTP parameters and desired email subject. Also set your Mastodon's full path. They will be saved to 'secrets/secrets.txt' for further use.
2. Run `python setup.py` to set your SMTP parameters and desired email subject. Also set your Mastodon's full path. They will be saved to `secrets/secrets.txt` for further use.
3. Run 'mailing.py' to start emailing your inactive users ('last_sign_in_at' older than a year). Their username, account_id, email, delivery status (True if successful) and delivery date will be written to Postgresql database. There is another column, 'deleted', False by default. Will be useful to track deleted/not deleted inactive users if you choose to do so.
3. Run `python mailing.py` to start emailing your inactive users (`last_sign_in_at` column older than a year). Their username, account_id, email, delivery status (True if successful) and delivery date will be written to Postgresql database. There is another column, `deleted`, False by default. Will be useful to track deleted/not deleted inactive users if you choose to do so.
4. Use your favourite scheduling method to set mailing.py to run regularly. Column 'elapsed_days' of mailing's database will be updated so you can decide actions after some time.
5. Run "delete_inactives.py' to delete all inactive users after 30 days period from the warning email.
5. Run `python delete_inactives.py` to delete all inactive users after 30 days period from the warning email.
Note: install all needed packages with 'pip install -r requirements.txt'
6. Run `python edit_status.py` to set True or False any of following `mailing_db_table` columns: `to_be_deleted`, `feedback` and `recipient_error`.
Note: install all needed packages with `pip install -r requirements.txt`

Veure arxiu

@ -50,7 +50,7 @@ def write_db(now, id, username, email, emailed_at, emailed):
cur.execute("UPDATE " + mailing_db_table + " SET elapsed_days=(%s), email=(%s), emailed=(%s) where account_id=(%s)", (delta, email, emailed, id))
print("Updating user " + str(id))
conn.commit()
cur.close()
@ -101,10 +101,10 @@ def email_sent(id):
if conn is not None:
conn.close()
conn.close()
###############################################################################
# Connect to Mastodon's Postgres DB to check if any inactive user is back online
# Connect to Mastodon's Postgres DB to check if any inactive user is back online
###############################################################################
def check_alive(id):
@ -193,7 +193,7 @@ try:
inactive_users_id.append(row[0])
else:
inactive_users_id = []
cur.close()
@ -210,7 +210,7 @@ finally:
i = 0
while i < len(inactive_users_id):
seen = check_alive(inactive_users_id[i])
try:
@ -231,7 +231,7 @@ while i < len(inactive_users_id):
last_year = datetime.today() - timedelta(days=365)
if reactivated == True or seen == None or seen > last_year: #if inactive user had reactivated its account or had deleted it we must delete related row from 'mailing_db_table'
cur.execute("DELETE FROM " + mailing_db_table + " where account_id=(%s)", (inactive_users_id[i],))
print("Deleting user " + str(inactive_users_id[i]))