Skip to content
Permalink
Browse files

Fix #1 - NoneType' object is not subscriptable

  • Loading branch information
salvadorpla committed Dec 1, 2019
1 parent e4a2f56 commit be741e599ae42f39894b5007ecda91133fcb4916
Showing with 11 additions and 3 deletions.
  1. +11 −3 mailing.py
@@ -49,7 +49,8 @@ def write_db(now, id, username, email, emailed_at, emailed):
delta = now-row[0]

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()
@@ -117,8 +118,11 @@ def check_alive(id):
cur.execute("select last_sign_in_at from users where account_id=(%s)", (id,))

row = cur.fetchone()
seen = row[0]

if row != None:
seen = row[0]
else:
seen = None
cur.close()

return seen
@@ -221,9 +225,13 @@ def get_parameter( parameter, file_path ):
email_datetime = row[0]
email_datetime = email_datetime.replace(tzinfo=None)

if email_datetime < seen:
if seen != None:
reactivated = email_datetime < seen

if reactivated == True or seen == None: #if inactive user reactivated its account or 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]))

conn.commit()

0 comments on commit be741e5

Please sign in to comment.
You can’t perform that action at this time.