Fix #1 - NoneType' object is not subscriptable

This commit is contained in:
salvadorpla 2019-12-01 12:40:48 +01:00
pare e4a2f56ae2
commit be741e599a

Veure arxiu

@ -49,6 +49,7 @@ def write_db(now, id, username, email, emailed_at, emailed):
delta = now-row[0] 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)) 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() conn.commit()
@ -117,8 +118,11 @@ def check_alive(id):
cur.execute("select last_sign_in_at from users where account_id=(%s)", (id,)) cur.execute("select last_sign_in_at from users where account_id=(%s)", (id,))
row = cur.fetchone() row = cur.fetchone()
seen = row[0]
if row != None:
seen = row[0]
else:
seen = None
cur.close() cur.close()
return seen return seen
@ -221,9 +225,13 @@ while i < len(inactive_users_id):
email_datetime = row[0] email_datetime = row[0]
email_datetime = email_datetime.replace(tzinfo=None) 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],)) 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() conn.commit()