Commit 3c4d9251 authored by Jonathan Schaeffer's avatar Jonathan Schaeffer
Browse files

Correcting slow deletion of temp users

parent 11e1dc04
......@@ -153,19 +153,19 @@ def cleanup():
raise e
cur.execute("select user_index,login from users where expires_at < now();")
for users in cur.fetchmany(1000):
logging.info("Deleting %s/%s old logins"%(len(users), cur.rowcount ))
try :
cur.execute("""
delete from credentials where user_index in (%s)
""", ','.join([u[0] for u in users]))
cur.execute("""
delete from users where user_index in (%s)
""", ','.join([u[0] for u in users]))
except Exception as e:
logging.error("Unable de delete from credentials or users")
logging.error(e)
conn.commit()
old_users = [u[0] for u in cur.fetchall()]
logging.debug("%d users to delete : %s"%(len(old_users), old_users))
try :
cur.execute("""
delete from credentials where user_index in (%s)
""", ','.join(old_users))
cur.execute("""
delete from users where user_index in (%s)
""", ','.join(old_users))
except Exception as e:
logging.error("Unable de delete from credentials or users")
logging.error(e)
conn.commit()
conn.close()
try:
......@@ -183,14 +183,9 @@ def cleanup():
application.config['PRIVILEGEDBPORT']))
raise e
logging.debug("Deleting from privileges database")
users_to_delete = ""
for uidx in users:
logging.debug(uidx)
users_to_delete.append("'%s',",uidx[1])
cur.execute("""
delete from eida_temp_users where name in (%s);
""", users_to_delete[:-1])
""", ','.join(old_users))
conn.commit()
conn.close()
return Response("Deleted %d temporary accounts."%(len(users)), status=200)
......
__version__='0.2.2'
__version__='0.2.3'
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment